I would most emphatically not recommend C++ Primer in any edition as a beginner level book for C++ programming, as it's definitely NOT made for a beginner in the language. As a review for someone that already knows the language? Yes.
Programming, Principles, and Practice Using C++ (the 2E) by Stroustrup is highly recommended. It's good, but it has several areas it fails, most notably chapters 5 to 7, where you'll undoubtedly fail many, many times. The first 4 start off reasonably well, and he does an excellent job making you think, introducing operators (+=, -=, ++, etc.) which is an area the next book I'll recommend falters hard. He also makes no mention of the array, which as far as I can tell you're better for not seeing. When you discover the vector, I can't think of any reason to bother with the array (another area the next book falters. He also regularly stops you with, "Try This" exercises to test you along the way.
That said, he expects you to use his premade header, rather than tell you the includes at the time, and in a rare case where I can see telling someone, "I know you have questions - just include #iostream now, and we'll cover it later" he DOES say that, but only with regards to his header. Also, chapter 5 is where the pace of the book starts to fail, and 6 and 7 are just awful. He gets into error handling, which we all know (or should know) is very important, but in my opinion he gets into exceptions and try blocks far too early for the beginner. He assumes you have no knowledge, and I get he wants to emphasize error handling, but from that point until chapter 10 (where I just gave up) cover error handling. I'm glad he wants to enforce good practice, however, throwing the occasional reminder, "Hey, programmer - did you notice something about the call area1/(area2 + area3)? Watch out for things like division by zero! Wink wink!" would have helped just as well to put me in the mindset of, "USE CAUTION!" 6 and 7 he begins work on a "simple" calculator, which is designed primarily to make you think about program design and the steps involved, but he false-starts it so many times to show pitfalls that it just gets confusing. Think of it like this:
1 2 3 4 5 6 7 8 9 10
|
//Our first example
char operator;
int val1, val2;
cout << "Enter an expression!\n";
cin >> val1 >> operator >> val2;
switch (op)
{
case '+':
cout << val1 + val2 << endl;
//now switch the other 3 signs
|
Simple starting point, yes? Well, it ends in the same chapter with:
1 2 3 4 5 6 7 8 9 10
|
//classes we haven't explained
//another class here
//remember parsing and complicated grammars? Hello again!
//set up those class definitions
//a few calls-by-reference we haven't explained
//here's the istream which you don't really understand
//tokens about putting values in, taking them out
//implement the functions
//OOPS! Were you error checking? Let's go back through it all and do that again
//Are we done? Not even!
|
Yes, it goes from effectively the first block of code where we just switched on an operator into a 150 line code of classes, tokens, grammars, exceptions, reference calls, iostreams, etc., most of which he acknowledges he hasn't discussed, but will!
I read through it no less than 10 times (not an exaggeration), and maybe I'm just "slow," but eventually I got to a point where I decided it wasn't really worth continuing, skipped to chapter 8, and the text got so terse, "Try this" effectively disappeared, and I was left very confused. Now, despite what you may glean from what I say, it's not a bad book. If the book had followed the pace of the first 4 chapters, I'd be standing in a robe holding the book up like some strange computer Moses commanding all ye who dare enter read it, but I just can't.
HOWEVER, I'm going back through all the basics to make sure I left no stone uncovered with Problem Solving With C++ 9E by Savitch, and it's the book I wish I had started with.
First off, it's unbelievably verbose - page 236 and I'm still on functions, whereas in the same area of Stroustrups book we would be discussing call-by-reference and fstreams. It also has yet to use operators we should be using (+=, -=, etc.) and I can see in the table of contents there's an in-depth explanation of arrays on the horizon, before vectors. HAVING SAID THAT...
It's plenty detailed, and is explaining things Stroustrup's book left me hazy on. Some aspects (such as function name overloading) are covered early, but not in too incredible depth, other things (++i, or i++?) are covered with many examples, as is scope, that even after working through Stroustrup I was hazy with. It covers good form and style, and in several areas answers questions I either didn't know I had but were excellent questions, or questions I had but never had a definitive answer. It's a surprisingly good book that NOBODY mentions. Maybe it turns really bad in the future? I don't know, but I'm not seeing it.
Between you and me? I'd say grab both, if you can. They complement each other very well, and I do like Stroustrup's book, I swear... but it has some serious faults in the pace ramping up too quickly and suddenly, and leaves out some very important details you probably SHOULD know.
Well, good luck. I'll probably be lynched after this post for not recommending one of the cornerstones of C++ programming books people swear by, and not praising the other enough, but as someone that has worked through a significant portion of all of them and still am (and PluralSight had 6 months free with MS access - DO NOT GIVE THEM MONEY) this is just what I get from them.