Return to Home Page
      Blog     Consulting     Seminars     Calendar     Books     CD-ROMS     Newsletter     About     FAQ      Search

C++ Inside & Out Chapter descriptions

The first four chapters of the book presents the syntax of ANSI C and draft-ANSI C++ (we must say "draft" until the specification is approved, a process which will no doubt result in another edition of this book). These chapters cover the features that are common between the two languages, describing the extensions that C++ adds to ANSI C, and especially flagging the places where they are different. These chapters focus on more than just the syntax of the language, however. When you begin writing larger programs in C++, you inevitably create many files that must be managed and compiled properly. In the first chapters you will learn the proper construction of multifile projects, emphasizing header files and the make utility (virtually all C & C++ compilers come with a make). All the programs in each chapter are compiled with the makefile, which describes the relationships in the projects. The makefile is placed at the end of each chapter.

The remaining chapters in the book cover object-oriented programming in C++. Here, you learn how to use the features presented in the first four chapters, and other new features in C++. Chapter 5 shows you how to "overload" operators and functions. Operator overloading means you can give and operator like + or - a special meaning when used with a new data type you create. Function overloading means you can create several meanings for the same function identifier, depending on the argument list.

Chapter 6 shows how to create objects at run time, for situations when you don't know at compile time how many objects you will need or what their lifetimes will be. Creating objects at run time is an extremely powerful feature of C++.

Chapter 7 demonstrates how code can be re-used in C++, both by using objects inside of other objects (composition), and through the mechanism of inheritance. Chapter 8 shows how to use inheritance to build extensible programs. Once you've built an extensible program, you or someone else can easily add features without ripping apart the existing code. The creation of extensible programs and the re-use of libraries are the two features of C++ which will save the most money in development projects.

Chapters 9-11 cover more advanced topics. Chapter 9 considers the thorny problems of passing and returning objects by value into and out of functions. Much emphasis is placed on the copy constructor X(X&), which often causes new C++ programmers a lot of grief.

Chapter 10 covers the very important OOP concept of container classes, and their associated iterators. These always make me think of Winnie-The-Pooh, arriving at Eeyore's birthday party and explaining his gift: "A pot ... to put things in" (on the way, he ate the honey inside). Containers are objects which hold other objects, and iterators are objects which point inside containers, move around and fetch objects back out. These are classes you write or get from someone, and are not built into the core language, but you use them almost as often as you use the other OOP language features. If they're so important, why isn't there direct language support? The template keyword is essentially language support for container classes, and Chapter 10 has extensive coverage of templates.

Throughout the book, I've tried to use interesting examples. I've tried to avoid repeating the typical textbook examples in favor of programs that have been useful, fascinating, or both. One of the more difficult problems in teaching this language seems to be the order in which concepts are introduced. Great efforts have been made to ensure a concept is introduced before it is used in an example, or at least to tell you where a concept is explained more fully, in the few cases where they are used prematurely. But for someone who loves the language like I do, it's very difficult to hold back from using a great feature because it hasn't been introduced yet. Therefore Chapter 11 is a relief, because I've introduced everything and can pull out the stops (in my next book, the equivalent of Chapter 11 will come sooner, because if you don't know some of the basics I'll refer you back to this book). This chapter has several complete examples, which provide you with some projects to sink your teeth into.

Changes From the First Edition

The original intent of this second edition was to simply update the book to match the new version of the language that is being supported by most compilers, to take out or update anachronistic material (for example, the common file extension custom used to be HXX and CXX or HPP and CPP, and now it has become the more sensible H and CPP), to support iostreams throughout the book rather than the less-powerful printf() family of functions, and also to include a chapter on templates and an appendix on exception handling.

However, as I reviewed more of the material and studied the code, I discovered places where I could greatly improve the explanations, and that some of the code designs were embarrassingly flawed. I am somewhat comforted by reminding myself that with pragmatic object-oriented design, you'll get it working the first time but you may not always get it right, and that at least the code can be improved easily. This turned out to be true — the fixes weren't as painful as they would be in another language.

Also, I began to realize that a lot of people who bought Using C++ were going to buy the new one, and I wanted to give them something so they'd feel it was worth it. In many places I got some inspirations which I hope you'll feel justify the additional cost of buying another book (see the last examples in Chapter 9, and the new examples in Chapter 11, for example).


Search     Home     WebLog     Consulting     Seminars     Calendar     Books     CD-ROMS     Newsletter     About     Contact     Site Design     Server Maintenance     Powered by Zope
©2007 MindView, Inc.