JonHoyle.com Mirror of MacCompanion
http://www.maccompanion.com/archives/january2006/Books/CppCookbook.htm

 

Newsworthy Events



C++ Cookbook

reviewed by Jonathan Hoyle

 



Authors: D. R. Stephens, C. Diggins, J. Turkanis, J. Cogswell

O'Reilly

https://www.oreilly.com/library/view/c-cookbook/0596007612/

Released: September 23, 2005

Pages: 592

$45 USD, $63 CND,
£32 GBP, €41 Euro

ISBN: 0596007612

Audience:
Intermediate C++ programmers.

Strengths:
Good practical examples, exercises in STL containers and algorithms, compiler independent.

Weakness:
Too focused on command line tools, no information on graphical IDE's.

As a C++ programmer, do you often find you have rewrite some of the same utilities over and over again, each time you start a new project?  Some might be simple things like converting numbers to strings and back again, or performing date/time arithmetic.  Others are more sophisticated, such as implementing the best STL container class for the job and using the appropriate STL algorithm.  Whether it's fine tuning some high performance mathematics for a scientific application, or subclassing your own stream class, the C++ Cookbook will have a solution for you.

Many C++ books have a strong Windows bias, typically assuming Microsoft Visual C++ as the user's compiler.  The C++ Cookbook however is truly a cookbook for all platforms.  In its introductory chapter, it reviews the many command line compilers supported, including: gcc, Visual C++, Intel, Metrowerks CodeWarrior, Cameau, Borland, C++ Builder, Digital Mars and others.  A frank review of how good these compilers are and their likely usefulness in the future is also given.  With so many C++ books feeling they must walk some politically correct line on compilers, this one is refreshing and informative.

The authors are thorough without being overbearing.  Case in point: an explanation on how (and why) you would build static and dynamic libraries for your project.  The information is separated by compiler and speaks directly to the necessary steps to follow, without dragging the reader through "beginner" explanations.  Building the Boost framework is done similarly.

Although the C++ Cookbook may lack the useful design diagrams found in similar books, its layout is clear and concise and obviates much of the need for them.  Each chapter opens up with an introduction to the topic it covers, with an excellent overview of what is to follow.  Then individual problems are introduced, each broken down into three parts: the Problem, the Solution and the Discussion.  The Problem is a simple sentence or two indicating the problem.  The Solution goes into technical detail, with pragmatic approaches for the solution, or solutions if there is more than one.  The Discussion is the most interesting part in my opinion, giving many of the caveats related to the problem and solution.

The first chapter is a thorough introduction of the compiler choices available and steps to build the Boost framework.  Chapter 2 covers various header file gotcha's, things every programmer hits at some point in his career, such as double #includes, multiple instances of a single variable, namespace collisions and the like.  Chapters 3, 4 and 5 cover common needs and optimal implementations for such things as number/string conversions, text manipulation, and date/time management.  Helpful techniques in using STL containers and algorithms take place in Chapters 6 and 7 respectively.  Chapter 8 is a delightful collection of class usage, with everything from singleton classes and operator overloads to templated classes and superclass virtual functions.  Chapter 9 describes custom exception classes, and Chapter 10 teaches you how to subclass your own stream class.

Chapter 11 is one of my favorite chapters entitled Science and Mathematics.  From the simplistic problems of computing the number of elements in a container, to the advanced computation of Fast Fourier Transforms, you'll find it here.  The most valuable part of this chapter, for most developers, is likely to be the section on fixed point numbers: getting floating point behavior out of the speed of integer math.   Multithreading using Boost is covered in Chapter 12, internationalization in Chapter 13, and some common XML solutions shown in Chapter 14.  The final chapter is an interesting assortment of miscellaneous problems, including the use of function pointers as callbacks, pointers to class members and others.

The wide range of topics in the C++ Cookbook realistically covers modern problems that software developers will encounter.  The examples are useful and serve as templates for code for which virtually every programmer will have a need.  This is another fine edition to O'Reilly's excellent line of C++ books.

About Us | Site Map | Privacy Policy | Contact Us | ©2006 MPN LLC.

http://www.maccompanion.com/archives/january2006/Books/CppCookbook.htm
http://www.maccompanion.com/macc/archives/january2006/Books/CppCookbook.htm