Some good points and bad points, but mostly good.
Probably more useful for someone who already knows how to program than for a beginner.
The video series by the Aussie would be of more use to a beginner.
I’m going to put all my nitpicks in a details block to avoid clogging up the thread.
(To be honest I’d probably find fault with any tutorial, I’m very picky.
They missed an important point at:
// C standard headers are available in C++,
// but are prefixed with “c” and have no .h suffix.
When using the c-prefix headers, there’s no guarantee that the contents will be included into the global namespace, there’s only a guarantee that the contents will be included into the
printf("Hello, world!\n") might not compile, you might have to use
I’m not keen on the fact they’ve shown a global
using namespace std; without explaining why that’s frowned upon.
(I only ever use
using namespace Pokitto; at function scope.)
They don’t mention it, but hopefully it will be obvious that
cin >> myInt will throw an exception if the input isn’t a valid
I’m upset to see
endl again. The problem with
std::endl is that it doesn’t just print a newline, it also flushes the output buffer, so having lots of them in a row slows down the program.
That’s fine for really short simple programs, but it’s a bad habit to learn and unfortunately its use in tutorials is the main reason it’s spreading.
The stuff about references was useful, glad to see references mentioned before pointers.
References should be preferred over pointers.
Disappointed to see plain enums being introduced before scoped enums, but at least scoped enums get a mention.
I detest classes named after animals used for inheritance.
It doesn’t adequately illustrate the concept of inheritance, often people get the wrong end of the stick.
The eventually mention “// Never put a “using namespace” statement in a header.”, but it’s a bit late by that point and they don’t explain why. Saying ‘never do this’ without explaining is bad because people take the rules to heart and forget why those rules exist.
The lack of
this-> disappoints me, but sadly not bothering with the
this-> is quite common.
Good to see initialisation lists being used.
Unfortunate to see a binary operator being implemented as a member function instead of a free function.
Point up (0,1); initialisation style runs the risk of hitting the most vexing parse problem
Good to see them mentioning the
>> problem with templates.
And that if you’re using C++11, you don’t have to worry about it
Their section about exceptions fails to mention that exceptions should not be caught unless they are either able to be handled or they are logged and rethrown.
Glad to see RAII is covered, I especially like that they are using it to demonstrate why exceptions are easier to work with than error codes.
goto failure; idiom of C was the main cause of Apple’s infamous
goto fail; bug.
The ‘fun stuff’ section neglects to menion that most of those bad/surprising things are C’s fault.
If C++ had made more of an effort to fix C’s problems then it would be an even better language than it already is.
The tuple stuff is pretty good, apart from the issues I mentioned in earlier sections (not qualifying with
std:: all the time, using the potential ‘most vexing parse’ syntax).
Containers should be covered earlier than they are, but otherwise is mostly good.
(Though there’s no reason to not declare the iterator inside the for loop expression.)
They could do with being a bit more in depth though, there’s a lot of stuff about containers that this doesn’t cover.
Logical operators should be covered a lot earlier.
No need to mention the ‘equivalent keywords’ because nobody uses those in real-world code.
Likewise for the bitwise operators.