C++ retains all the standard procedural programming features of C. It uses a basically similar style for variable and function declarations; has selection statements (if(...) ...;else ...; and switch(...) { ... };); iteration statements (for(...;...;...), while(...) ...; and do ... while (...);); and flow control statements (break; continue; return ...; and even goto). The "block structure" is similar to C, as are the scope rules for all variables that are not parts of classes. None of these standard aspects of coding are covered in the next three chapters; all are assumed to be familiar to readers.
The first rather short chapter covers some extensions that C++ provides that are relevant to normal, procedural-style code. These include minor differences, such as new styles for comments, as well as more significant changes, such as "overloaded function names" and the new type-secure "stream i/o" that should be used in preference to the ISO/ANSI C i/o libraries.
The next chapter adds a touch of class. C++ classes are introduced through examples. Rather than present a definition of C++'s class with all its features, a series of examples is given that successively add more capabilities.
The first examples, Point and Rectangle, are archetypical "abstract data types". The class declarations define the form of new structures (like a typedef struct in C, or a Pascal Type x = record ... end declaration). But, as well as specifying the data fields ("data members") in these new record types, the C++ declarations specify controls on access to these fields and nominate the procedures ("member functions and friends") that should be used with instances of the new record type. (In the rest of this text, the term "programmer defined type" will be used in preference to "abstract data type"; it is a more apt description of the entities like Points, Rectangles, and Lists that are being defined and used.) The Point and Rectangle examples illustrate how the author of a class can, by defining the semantics of operators such as = (assignment) and '+', integrate a new type so completely into the language that it appears to be a "1st class type" having the same status as built-in types like integer (int) or character (char). It seems a fairly safe prediction to assert that all C programmers, no matter how hidebound and reactionary, will eventually adopt C++ if only to obtain these capabilities for defining "1st class" data types.
Another example, class Player, introduces some of the complexities in classes, such as the need for the class author to manage any separately allocated storage, or other resources, that must be controlled by instances of a class. In the next section, class LinkedList and its associates Link and LinkedListIterator illustrate how a group of classes can be designed to work together; in this example, an instance of class LinkedList uses many instances of class Link when building up its data store. While simpler classes like Point and Player may be conceived and used in isolation, most of the more complex classes exist as parts of small "clusters" with strong ties existing among instances of the different classes in a cluster.
Class Assoc, that implements a form of association list, is used to illustrate another standard object-based programming style - the delegation of work to a "subcontractor". Class Assoc doesn't handle any storage management, preferring to delegate this work to an instance of class LinkedList. Class LinkedList was invented for one application, and ends up being reused by many other classes as a component or subcontractor.
Finally, an example class ChemicalStructure is used to explain the role of "static" members in C++ classes.
The third chapter in the section illustrates classes with inheritance and support for an object-oriented style of programming. Here, the Space Invaders program is revisited and a simple implementation is given that illustrates single inheritance, polymorphism, dynamic binding - and all the other fun features of an OO programming style.
Some more advanced features of C++, such as support for multiple inheritance, are taken up Chapter 12.
The materials in these chapters should be supplemented with material from one or more of the following books: