This site will look much better in a browser that supports web standards, but is accessible to any browser or Internet device.

Anomaly ~ G. Wade Johnson Anomaly Home G. Wade Home

May 24, 2005

Review of C++ Primer (Fourth Edition)

C++ Primer (Fourth Edition)
Stanley B. Lippman, Josée Lajorie, and Barbara E. Moo.
Addison -Wesley, 2005.

Every now and then, someone asks me to recommend a book for learning the C++ programming language. Until very recently, I didn't have a good answer. The book I learned C++ from went out of print years ago (and would be horribly out of date by now). There are lots of books that teach beginning C++, but I hadn't read one in years.

That has all changed. In the last few years, there have been two books with a new approach to teaching C++ that I have actually liked. The first was Accelerated C++. That book provides a good way to get your feet wet in C++. Unfortunately, the C++ language is so big and rich that it was not able to really do the subject justice. Now, the fourth edition of the C++ Primer comes out and uses a similar teaching technique and strives to cover the whole language. Amazingly enough, I think it succeeds.

The approach to teaching C++ that I learned was to start with an understanding of C. We start with the C way of doing things and introduce the C++ features on that base. Eventually we replace C features with C++ and the training is complete. This book takes a different approach. Since the authors are teaching C++, the C way of doing things is ignored from the beginning.

We get std::iostreams and std::strings almost from the very beginning. When we first need to collect multiple items of the same type, we are introduced to std::vector. C-style strings and arrays are discussed much later in the book, as relatively minor features of the language. In fact, when arrays are eventually introduced, the authors spend a fair amount of time describing their deficiencies when compared to vectors.

The readers of the book are also introduced to the use of classes and objects the same way they are introduced to int and floats. Time is spent explaining how to use the library classes with plenty of exercises and examples long before the reader is shown how to construct their own classes. I feel this approach does a much better job of acclimating the new programmer to objects than the older approach which began by trying to build classes.

In addition to the different style of teaching, this book also has relatively complete coverage of the language and libraries. Some of the sections on the standard containers and algorithms actually made me think about those tools in new ways. This is despite my having used those classes for a large number of years. The book also includes a few sections on more advanced topics that might not be appropriate for the C++ beginner. But these sections are well labeled and the reader is warned to skip ahead until some of the earlier material is completely mastered.

In a book this size, it would be hard to get everything exactly right. I found a number of minor editing errors, as well as a few style issues that I thought might not serve a junior programmer well. Other than that, my only complaint is that it is a big book (weighing in at 885 pages including index).

All in all, I plan to recommend this book to anyone wanting to learn all of C++. This is a terrific introductory book that covers enough of the language to keep someone learning for quite a long time. It also covers enough best practice sort of information to make certain that a novice programmer is steered away from some of the worst mistakes.

Posted by GWade at May 24, 2005 10:22 PM. Email comments
G. Wade Johnson is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to amazon.com.