REVIEW - C++ by Example


Title:

C++ by Example

Author:

Steve Donovan

ISBN:

Publisher:

Que Publishing (2001)

Pages:

389pp

Reviewer:

Francis Glassborow

Reviewed:

June 2002

Rating:

★★☆☆☆


Because I am about to list a number of poor aspects of this book, let me say that I like this book and will give my reasons for doing so latter on.

The author has a not uncommon habit of assuming that his style is the norm and accepted by most programmers. For example on the subject of names on page 14 he writes:

Most programmers prefer to make all variables all in lowercase and use underscores to separate words (for example one_dog rather than onedog).

This is a minor wart but one that could have been avoided just be (in the example I quote) replacing 'Most...prefer' with 'One common convention is...'

I, personally, do not like the style of naming that places const and enumerated values all in uppercase. I find that it detracts from the readability of code and makes it vulnerable to interference by the pre-processor.

Rather worse is that when he first introduces enum he does so in the context of using enumerations as a replacement for const int, and uses anonymous enum. The supporting text quite correctly states that the purpose is to avoid putting mysterious numbers in programs. He also comments that many people think it is a better style to use a const int rather than an enumeration. I would rather that he had just left enum for latter.

There are rather too many places where inadequate proofing and technical reviewing has allowed through errors that may confuse the reader. A good example of this is found on pages 152/3. On page 152 we find a little function that called draw_tree that takes five parameters, the first is a reference to a TG (a type that supplies both a turtle and a window for it to operate in), the last two parameters have reasonable defaults. That means a simple call of the function would look something like:

// code creating a TG, tg for example,

// and initialising its turtle

draw_tree(tg, 5.0, .7);

However on the facing page we find two figures giving examples of its use. However the stated calls both start with a double and hence will not match the defined function. While experienced programmers will spot the error at once and quickly fix it, the novice may struggle.

The author tends to write his code in a pre-exception style. He also skips quite a few aspects of the language and underplays certain aspects. For example I am less than happy with his treatment of virtual destructors. However there is nothing that could not be corrected in a second edition if the author had, and responded to, a couple of good technical reviewers.

Now let me look at the positive aspects of this book. The author does not waste time teaching the reader about C, he gets straight in and uses such features of C++ as string and vector. I am a little dubious with how far he takes this as I note that we have map turning up pretty early on. Perhaps this means that some prior programming experience would be an advantage. However he has one fantastic added quality for this book; it comes with an interpreter for C++ which is one of the items on the accompanying CD(that is the UnderC of the title). What amazed me is that this interpreter works with such a large part of C++. It manages templates and, as far as I can determine, all the code used in the book works with UnderC. However not all the C++ Standard Library ships with UnderC. Error messages are pretty minimal, but in an interpreted environment that is less of a problem. The CD with the book also includes the Free Borland C++ compiler and the GCC Mingw one. I have not tried to see what happens if I try STLport with UnderC but if I get some spare time I might try it out of curiosity - and I would be delighted if someone else tried this and reported it for the Member's Experiences column. By the way you can get the most up to date version of UnderC from http://home.mweb.co.za/sd/sdonovan/ccbx.htm. Where you will also find a version of Quincy (a free IDE that will work with the interpreter as well as the two C++ compilers provided on the CD). I would also like a report of that for C Vu.

The second thing that is special about this book is the inclusion of a turtle graphics class for Windows. As far as I can determine this also comes as standard with UnderC. This allows the reader to try some visually more interesting programs.

The genuine attempt to teach C++ as a free standing language (not dependent on prior knowledge of C) coupled with a good C++ interpreter and supported by a nice little graphics package makes this book stand out from the crowd. When a reader has finished studying this book and working with the examples they will have a reasonable foundation. More to the point, they will have been motivated to experiment. They will still need to learn a lot more and be careful of some of the detail from this book. However this is a rare book among those aimed at novices in that its strengths go a long way to balance its weaknesses. I will give this book a time limited recommended. By that I mean that I think it will remain a good starting point for a couple of years until, hopefully, it is replaced by a reworked and improved second edition.


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.