REVIEW - C++ for programmers


Title:

C++ for programmers

Author:

Leendert Ammeraal

ISBN:

Publisher:

John Wiley & Sons Inc (2000)

Pages:

453pp

Reviewer:

Yechiel M. Kimchi

Reviewed:

October 2000

Rating:

★☆☆☆☆


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:

  1. 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.
  2. 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).
  3. 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).
This comment is very problematical, because according to the current literal text of the C++ Standard Ammeraal is right. However, that is unlikely to survive a defect report because it surprised members of the C++ Standards Committees when they realised how the final words read. FG Multiple inheritance is dealt with in less than a page. It does not even mention that this subject is complicated. In that case, multiple inheritance should have been omitted altogether.

However, the following problems are too important to ignore and, in my view, warrant 'awarding' this book the infamous 'not recommended' mark:

  1. 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.
  2. 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]
  3. It seems that the author does not have even a clue about
    static_cast
    and
    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_cast
    is required for the conversion from B* to D*.
    Almost every non-toy C++ program will crash if the above advice is followed.
reinterpret_cast
seems 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

Book cover image courtesy of Open Library.





Your Privacy

By clicking "Accept Non-Essential Cookies" you agree ACCU can store non-essential cookies on your device and disclose information in accordance with our Privacy Policy and Cookie Policy.

Current Setting: Non-Essential Cookies REJECTED


By clicking "Include Third Party Content" you agree ACCU can forward your IP address to third-party sites (such as YouTube) to enhance the information presented on this site, and that third-party sites may store cookies on your device.

Current Setting: Third Party Content EXCLUDED



Settings can be changed at any time from the Cookie Policy page.