Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

[C++] Which programs to write to learn more C++?

  1. May 2, 2015 #1
    Alright guys so I just finished my freshmen intro course in c++ and I found it interesting. This course only taught up to classes and file i/o. I want to learn more of c++ and overall many more programs. How do I teach myself c++ more indepth or are there any free sites you recommend to learn it or any other program?
     
  2. jcsd
  3. May 2, 2015 #2
    I've been looking at 'C++ From the Ground Up' by Herbert Schildt (on the regrettably few occasions when I have time) and I've found it helpful, with unpacked explanations of what each piece of the code is doing along with other tips and things to be aware of. It goes all the way through from complete beginner level but you can just skip ahead to whatever suits your previous experience.

    It is quite behemoth of a book, so you'd probably keep it at home, but my copy says $34.99 which is less than I would have expected for such a huge book. I avoided paying though by getting it from my university library, which is worth doing if you can. You might find the library has other books you like as well/instead.
     
  4. May 2, 2015 #3

    D H

    User Avatar
    Staff Emeritus
    Science Advisor

    Don't use that book. Look up the term "bullschildt".
     
  5. May 2, 2015 #4
    I would recommend the book SICP by MIT. Even though it isn't in C++, rather Scheme. It's a great intro to CS book, and by the time you are done you will be a better coder for sure.
     
  6. May 3, 2015 #5

    jtbell

    User Avatar

    Staff: Mentor

    I suggest Koenig and Moo's "Accelerated C++". Although it's supposedly for beginners, it takes a very different path from most C++ textbooks. It focuses on the container data types in the standard library (vector, string, list, set, etc.) instead of C-style arrays and pointers like most intro books do (or at least did when I used to teach intro C++).
     
  7. May 3, 2015 #6
    I second Accelerated C++ (by Koening) and agree with avoiding Schildt.
     
  8. May 4, 2015 #7
    I looked at these books online and they look pretty helpful and I will probably get them, but is there a good free way to learn programming or should I go with the book.
    I just got out of college for the summer and moved back home so I do not have access to the school library
     
  9. May 4, 2015 #8
  10. May 4, 2015 #9
    Thanks. Also, if I want to get a minor in computer science, what would be most helpful to learn to prepare myself?
     
  11. May 4, 2015 #10
    I don't actually know what a minor as I am unfamiliar with the terms used by your country's (USA?) education system.

    However if you do an honours degree, as in BSc, then Computer Science is heavy on mathematics no matter where you study it. In some cases it's more maths than programming. You'd probably want to look at a branch of mathematics called "discrete mathematics". The best thing to do is look on university websites and see the structure of their course, to give you an idea of what is in it.

    I assume you are also aware of the difference between Computer Science and the other computing degrees?
     
  12. May 5, 2015 #11
    I have a computer science degree. This is what I use when I need to know something about C++: www.cplusplus.com. There is also C In a Nutshell (I think there is a C++ version too.) In response to what you need: math. Specifically boolean math, proof by induction, boolean operator identities:
    x | (y & z) = (x | y) & (x | z)
    !x & !y = !(x | y)
    x & (y | z) = (x & y) | (x & z)
    ....
     
  13. May 5, 2015 #12
    We used to play documentation roulette with cplusplus.com. You picked a random page on the documentation and if there were precisely zero errors on the page, you survived. Otherwise, you were eliminated.
     
  14. May 6, 2015 #13
    Oh, that sounds like fun. I haven't run across very many errors in documentation there though.
     
  15. May 6, 2015 #14

    D H

    User Avatar
    Staff Emeritus
    Science Advisor

    cplusplus.com was notorious for having lots of mistakes. It's not a community-developed product (e.g., wikipedia is a community-developed product), so it takes a while for errors to be corrected. If the author of a page doesn't think there is a mistake (but there is), it can take a long, long time for that error to get corrected. The community-developed competitor to cplusplus.com is en.cppreference.com. Errors in content are quickly corrected. Errors in context (an overly-technical, very unclear explanation): Those aren't so quickly corrected at cppreference.
     
  16. May 6, 2015 #15
    cppreference tends to avoid idioms and contextual issues as they're complex and mostly based on consensus, or require advanced understanding.

    I noticed this on the 2nd page I checked when OP linked cplusplus.com.

    std::list on cplusplus.com
    The first part I haven't a problem with. However the second part, sorting? You don't have random access so you are limited in your choice of algorithms, and how are you obtaining the links to the insertion points without iterating? Once you iterate over a linked list, it performs worse than a vector. In fact in most cases I have seen, you could insert into the middle of a vector, copying everyhing down 1 element, quicker than you can find the insertion point to do the same thing in a list. Traversing all those pointers plays hell with your cache pipeline.

    Of course, as in all cases, profile your code if it matters. :-)
     
  17. May 6, 2015 #16

    D H

    User Avatar
    Staff Emeritus
    Science Advisor

    They really shouldn't write stuff like that, should they?

    In their favor (I'm being generous), if it's a std::list<MyReallyBigHonkingClass>, there might be something to be said for sorting a list versus sorting a vector. The swaps used by std::sort will be expensive in this case. But ... they're stuck with something like mergesort to sort a list; no quicksort, heapsort, introsort, and they still have to traverse the list, on the order of N*log(N) times.

    Oftentimes, it's faster to copy to a vector, sort that, and copy back to the list than it is to use std::list::sort.

    Of course.
     
  18. May 6, 2015 #17

    RaulTheUCSCSlug

    User Avatar
    Gold Member

    The best way to learn C++ is to think of what you want to do with the programs and try to apply it! Perhaps try to simulate physics models with them or something of the sort. Now although there will be guides online to do this. There will be plenty of forums (this one included!) that would love to help you with any ideas that you might have. I know C from programming an Arduino, and I found following tutorials very dull, and I found it more enjoyable to think of an experiment or a project and tackling it head on and felt like I learned a lot more head on!
     
  19. May 7, 2015 #18

    HallsofIvy

    User Avatar
    Staff Emeritus
    Science Advisor

  20. May 7, 2015 #19

    RaulTheUCSCSlug

    User Avatar
    Gold Member

    Hallsoflvy is right, they are both objective languages and JAVA is a very useful language to learn! Very applicable and is used to program the apps on Androids. I might suggest learning python too, but it doesn't seem to be as useful or as widely known as C and JAVA. If you want something that you can make cool projects with, then starting with a raspberry pi would be a great idea!
     
  21. May 7, 2015 #20

    HallsofIvy

    User Avatar
    Staff Emeritus
    Science Advisor

    Another very nice property of Java is that you can download a Java compiler, for free, at https://www.java.com/en/download/help/index_installing.xml [Broken]
     
    Last edited by a moderator: May 7, 2017
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: [C++] Which programs to write to learn more C++?
Loading...