Accelerated C++: Practical Programming by Example

"Accelerated C++: Practical Programming by Example" is written by Andrew ... program. This chapter prepares the reader with no C or C++ experience to be able ...
9KB taille 126 téléchargements 328 vues
Accelerated C++: Practical Programming by Example "Accelerated C++: Practical Programming by Example" is written by Andrew Koenig and Barbara E. Moo, and published by Addison-Wesley, 2000 paperback, 0-201-70353-X, 352 pp., $33.95. I am impressed by this book. In "Accelerated C++" Andrew Koenig and Barbara Moo have written a book that starts off by teaching the reader how to efficiently use C++ to write programs, rather than spending chapter after chapter on the details of creating classes prior to the reader having any framework in which to appreciate them. "Accelerated C++" is written for the person who wants to quickly learn to be productive in C++ and is willing to leave the detailed intricacies of the language until later. The authors assume no previous experience in C or C++ although they do assume that the reader has both a modern implementation of C++, meaning it includes the standard library, and that the reader knows how to enter a program into a machine, compile and run it. The book begins with a brief examination of the components that make up a C++ program. This chapter prepares the reader with no C or C++ experience to be able to follow the examples and explanations in the following chapters. After this short introduction to the language, the authors present a program example that makes use of the standard library. This sets the tone for much of the first half of the book. Koenig and Moo spend almost exactly half of the book teaching the basic constructs, such as looping and decision making, while emphasizing the use of the standard library to simplify programs and to allow a novice user to build impressively useful programs by relying on the facilities provided by the standard library. It is also during this portion of the book that two other features stand out. At the end of each chapter is a section called Details. In it, the authors review each of the new programming or language topics that were introduced in the chapter, often providing additional details that would have been distracting if they had been included in the initial discussion. This is followed by between five and sixteen additional exercises to reinforce the topic matter from the preceding chapter. By the time the reader has worked through Chapters 0 through 7, he should have a good understanding of the basics of C++ and of how to use the standard library to implement such things as strings, vectors, lists, and associative containers. At this point, the student has also been introduced to some of the more common algorithms included with the standard library, such as sort, accumulate, find, copy, and search along with the use of iterator adaptors. Beginning with Chapter 8, the authors begin introducing the C++ concepts that provide much of the power behind the language. Writing generic functions is the topic of Chapter

8, followed by user-defined types, or classes, memory management, and abstract data types. During each of these chapters, the concepts that are being developed are illustrated with well-chosen code examples. In Chapter 13, the authors introduce inheritance and polymorphism via a handle class that simplifies and clarifies the solution to a problem presented earlier in the book. This is another exemplary trait of this book. The authors often show a code example to illustrate a concept, and then revisit the same example multiple times to show how more complex language features can significantly improve the performance, user interface, or robustness of the solution. Chapter 14 introduces the concept of reference counting to allow the user to create generic classes that encapsulate the error prone pointer manipulation that often accompanies maintaining objects while also giving the user the ability to decide when an object copy should actually involve copying the entire object or just creating another reference to it. This chapter discusses some fairly sophisticated concepts in C++, such as reference counting and template specialization through additional indirection to solve some otherwise difficult problems with virtual functions. The authors wrap up with one more visit to an earlier program example where they modify the previous solution to use abstract base classes, virtual functions, and reference counting to provide an elegant, much more efficient solution than the original. The book closes with two appendices. The first summarizes the details of the C++ language and syntax. The second appendix provides a summary of the C++ standard library. I really enjoyed this book. It is the first C++ book I have read that didn't leave me frustrated after the first several chapters. The approach taken to teach the language by first teaching the reader to use the base features of the language along with the standard library components and then moving on to the definition of classes, inheritance, and polymorphism is an approach that worked wonderfully for me. By the time the authors were ready to discuss these topics, I was ready to put them in a context I could understand. There is also a web page for "Accelerated C++" at www.acceleratedcpp.com. As of this writing, the web page only contains an errata list although the authors promise that it will contain machine readable copies of at least some of the example programs along with other useful C++ information. For those of you who are tempted to check this site, be forewarned. Although the errata list looks rather large, it is the result of the author's perfectionism rather than serious errors in the text. If you want to rapidly learn to be productive in C++ and are not concerned about becoming a language lawyer, this is an outstanding book. After working through "Accelerated C++" you should be prepared to tackle one of the more scholarly tomes, such as Bjarne Stroustrup's "The C++ Programming Language" to get the additional details and in-depth

understanding you will need to truly master the language. My thanks go out to Andrew Koenig and Barbara Moo for an exceptional book and approach to teaching the C++ language. © Copyright 2000 by Kenneth R. Frazer,