At first sight this book did not appear so bad: while leafing through it I noticed that the author had successfully avoided the most common errors of the worst books (e.g,
void main(), badly constructed constructors). The fact that I spotted several errors, as well as unfortunate explanations did not put it automatically on my 'not recommended' list, though it prevented it from being put on the 'recommended' list. In addition, it seemed to have nice chapters on STL and streams. It could have been just one of those books that would not do too much harm despite the fact that it would force you to relearn from a better book if you wished to become better than just a casual C++ programmer.
I was wrong. While reading the book I found too many fundamental errors that, in my opinion, are truly harmful, will impair the reader's understanding of C++ and will prevent her from correctly programming in C++. So I stopped reading just before the final chapters on STL and streams. Even if they are perfect, they will hardly do any good. You are better off reading a good book cover to cover.
I believe I owe both the author of the book and the readers of this review an explanation about the distinctions I make between apparently mild errors (that are not always mild) and truly harmful errors. Here are a few comments/errors that would not justify putting this book on the 'not recommended' list:
- The book title implies that it aims at readers who already know how to program, so why does it have a section (1.3) that explains binary and hexadecimal representation? Moreover, in my opinion, this section is both incomprehensible and confusing to anyone who is not familiar with programming.
- When explaining iteration statements (2.5) the author really misses the opportunity to explain the differences between a for-loop and a while-loop (in fact, only the syntactical differences are mentioned, together with the immediate semantics).
- The author claims that all assignment operators must be member functions (e.g, +=, p. 180). This is not true (cf. B.Stroustrup 3rd, 11.2.2).
However, the following problems are too important to ignore and, in my view, warrant 'awarding' this book the infamous 'not recommended' mark:
Testing successful input should be taught right at the beginning, but in this book it appears in chapter-10 (the last one - chapter 11 is a kind of appendix). Here is a while header from the book (p. 51):
while (cin>> i, i> 0)Apparently, this example is used to explain the usage of the comma operator. Alas, the alternative code
while (cin>> i&& i> 0)
is so much superior to the original, that I consider this example to be deceptive for innocent readers.
From page 121 (top), explaining arrays as function-parameters: 'Note that the array length is omitted in
a;if we had written it, then it would necessarily have been a constant, which would have made the function less general and elegant.' The above statement is poppycock. Do not take my word for it - just read a decent book about C. [Well, Ammeraal is wrong, but this is also a book about C++, so appeals to books on C are inappropriate. FG]
It seems that the author does not have even a clue about
reinterpret_cast. This is illustrated in various places in the book and I have chosen one such example (p. 205, bottom): If B is a base class from which D is derived, ... implicit conversion from D* to B* is possible, while a
reinterpret_castis required for the conversion from B* to D*. Almost every non-toy C++ program will crash if the above advice is followed.
reinterpret_castseems to cause a great deal of misunderstanding, the sad thing is that technical reviewers too often miss its abuse and thereby do authors a disservice. The correct cast in the above is almost always a
dynamic_cast. FG To conclude, I was left with one curious question: why is the example about function objects (section 6.16) so much better than all other examples? My answer: who cares? More examples of errors can be found on my pagehttp://www.cs.technion.ac.il/users/yechiel/CS/BadBooksC+C++.html#AmmeraalCPP4ProgNot Recommended.
If anyone would like to take a second look at this book, I can provide a review copy. If you are wondering, this is because this review seems to conflict with other reviews of Ammeraal's books. - FG