Please don't touch "The C Programming Language" if you care about modern C++, as you will learn lots of idioms that are good in C, but the WRONG THING in C++.
Better learning path:
- A Tour of C++, Bjarne Stroustrup
- The C++ Programming Language, 4th Edition, Bjarne Stroustrup
- Programming: Principles and Practice Using C++, Bjarne Stroustrup
- The Design and Evolution of C++, Bjarne Stroustrup (how C compatibility got to influence C++'s design)
Additionally read everything you can from Andrei Alexandrescu and Scott Meyers.
The best introductory text to modern C++ is, in my opinion, Accelerated C++ by Moo and Koenig. It's concise and teaches the language instead of spending 6 chapters teaching fundamental algorithms (yet another broken linked list class!) or OO principles (which often results in terrible C++).
It's more targeted at people who do not know C. Koenig argues that building on C knowledge to learn C++ is a bad idea. They discuss this in the preface of the book.
Though I also recommend this book, their example code teaches bad habits (such as assignment within conditionals and horrendous compound statements) which should be avoided in any sort of production code.
Do you have any examples? I just flipped through the book and couldn't find any. Accelerated C++ was my first ever programming book. It was quite a doozy to get through at the time, but I feel like I'm forever indebted to it. Koenig's attention to detail and ability to explain what the machine is actually doing and the consequences in your code is still unmatched as far as I can tell.
I actually like using the ternary operator in this sort of assignment, so I only need to type the variable name once instead of 3 times. The only real problem in your example is that everything is in one line. It woulf be better to indent that and to add some extra parenthesis to make the precedence clearer.
+1 for Inside the C++ Object Model. Understanding the mechanics of abstractions like virtual methods (along with stack/heap, pointers, but those are less C++-specific) makes you much more confident in what your code is doing (and why you might do it that way).
A lot of the key C++ books in my library are outdated as far as C++11 or 14, but still are pretty valuable especially for legacy code bases. Here are a few good ones that I haven't seen mentioned elsewhere in the thread.
- Sutter's Exceptional C++ books
- Dewhurst's C++ Common Knowledge and C++ Gotchas are useful.
- Sutter/Alexandrescu's "C++ Coding Standards" is good, too.
I second many of the books, but in particular "Sutter/Alexandrescu's C++ Coding Standards"
the "coding standards" is misleading, its more like a "Code Complete" for hardcore C++.
C++ FAQ Lite is not a book, but a great reference; this is useful the night before an interview. It's helpful. It certainly did help with my interview.
No mention of C++ Primer? A rather thorough (if a bit overwhelming) introduction to the language. And it teaches idiomatic C++, not just C with classes.
This is what I recommend to all my friends who want to learn C++. It's a little terse on some of the more advanced concepts but gets the job done very well.
I'm a really big fan of Effective C++ and More Effective C++.
The syntax of a language is fairly easy to grasp, and I think the more important thing is to learn how people use the language, what are the pitfalls you're likely to encounter, and how to code around them. Essentially a "best practices" guide.
It's great that C++ has these books. With some other languages its not obvious what the "best practices" books are or there don't seem to be any.
C++ provides many more ways to shoot yourself in the foot than most other languages, so it is in more need of such books.
For coding in C#, Framework Design Guidelines[1] is an excellent book. I'd argue that with a little adjustment for conventions, it applies to Java too - and IMHO Java is in more need of the advice, as test-oriented code can lead to unwieldy, overcomplex APIs, a tendency that needs tempering.
Lakos works at Bloomberg and his design principles from the book have been in use there for over a decade. The book content might seem strange for someone coding on their own, but when you have a staggering amount of C++, the order it brings to the chaos is welcome. If you wind up reading it you can see the concepts in practice in our GH repo (bloomberg/bde), which might make it an easier read.
Lakos is the most influential (to me) programming book I've ever read. It came out perfectly timed, as I was moving from lone coder to lead coder, and the videogames industry was growing from 1-2 coder teams into 5+ teams, from thousands to millions of LOC and from C to C++.
Would it be counter productive to learn C++ using Stanford School of Engineering Introduction to Computer Science Programming Abstractions[1] CS106b considering it was taught in 2008?
I cannot judge on the quality of the course, but there are a lot of horrible C++ resources (including books) out there and over the years the community has come to a kind of consent which resources are likely produce C++ programmers which shouldn't be shot on sight.
I am about to finish CS106a which is designed in similar fashion. It uses ACM libraries. It was my first programming course and I think I did great[1]. Mehran Sahami is a great teacher and he presented lectures in a very digestible fashion. Also assignments are designed in a very doable way. It all turned out to be a very pleasing experience. There is no end to learning so I will have to spend some time learning the main Java class.
It also only supports Mac(Xcode) and Windows(VB) but I would like to use something like Qt-Creator on Linux.
I've been looking for a good book that teaches idiomatic C++11 programming from scratch. Something like Accelerated C++ or Programming: Principles and Practice Using C++ but using C++11/14 only. Lots of the C++11 books I've found have assumed you know C++98 and say what the differences are. Anyone have any suggestions?
The 4th edition of "The C++ Programming Language" has been updated to cover C++11. Contrary to the article I think the book is very well suited to learn C++ (although not to learn programming). It takes a bottom-up approach making it suitable for people that have no previous exposure to a similar language.
Would you recommend that a novice programmer learn C++ these days? Just seems like the ROI is too little in terms of new concepts that'll be learned. I mostly suggest C -> Java/C# -> Some functional language and also Python/JS on the side.
I would. C++ is still really important for low level algorithms. One can always do some low level programming with Java or C#. But is not as effective when it's done with Java/C#.
I was asked this question,but could not come up with a good answer:Assuming someone has never programmed before,but has the (mis)fortune of using C++(e.g that is what the school he/she is enrolled in uses) what would be the best book to start with?
This is pretty far from an introductory C++ book, but I'd like to mention "Modern C++ Design" by Andrei Alexandrescu. Back when I was writing C++ code, this was the book that really opened my eyes to what you could do with the language.
Better learning path:
- A Tour of C++, Bjarne Stroustrup
- The C++ Programming Language, 4th Edition, Bjarne Stroustrup
- Programming: Principles and Practice Using C++, Bjarne Stroustrup
- The Design and Evolution of C++, Bjarne Stroustrup (how C compatibility got to influence C++'s design)
Additionally read everything you can from Andrei Alexandrescu and Scott Meyers.
Then maybe, read The C Programming Language.