(Note:
All chapters conclude with a Summary.)
I. INTRODUCTION TO PROGRAMMING WITH C++.
1. Object-Oriented Approach: What's So Good about It? The Origins of the Software Crisis. Remedy 1: Eliminating Programmers. Remedy 2: Improved Management Techniques. The Waterfall Method. Rapid Prototyping. Remedy 3: Designing a Complex and Verbose Language. The Object-Oriented Approach: Are We Getting Something for Nothing? What Does the Designer Do? Design Quality: Cohesion. Design Quality: Coupling. Design Quality: Binding Together Data and Functions. Design Quality: Information Hiding and Encapsulation. Design Issue: Name Conflicts. Design Issue: Object Initialization. What Is an Object, Anyway? Advantages of Using Objects. Characteristics of the C++ Programming Language. C Objectives: Performance, Readability, Beauty, and Portability. C++ Objectives: Classes with Backward Compatibility with C.
2. Getting Started Quickly: A Brief Overview of C++. The Basic Program Structure. Preprocessor Directives. Comments. Declarations and Definitions. Statements and Expressions. Functions and Function Calls. Classes. Dealing with Program Development Tools.
3. Working with C++ Data and Expressions. Values and Their Types. Integral Types. Integer Type Qualifiers. Characters. Boolean Values. Floating Point Types. Working with C++ Expressions. High-Priority Operators. Arithmetic Operators. Shift Operators. Bitwise Logical Operators. Relational and Equality Operators. Logical Operators. Assignment Operators. Conditional Operator. Comma Operator. Mixed Expressions: Hidden Dangers.
4. C++ CONTROL Flow. Statements and Expressions. Conditional Statements. Standard Forms of Conditional Statements. Common Errors in Conditional Statements. Nested Conditionals and Their Optimization. Iteration. The Use of the WHILE Loop. Iterations with the DO-WHILE Loop. Iterations with the FOR Loop. C++ Jump Statements. The BREAK Statement. The CONTINUE Statement. The GOTO Statement. The RETURN and EXIT Jumps. The SWITCH Statement.
5. Aggregation with Programmer-Defined Data Types. Arrays as Homogeneous Aggregates. Arrays as Vectors of Values. Defining C++ Arrays. Operations over Arrays. Index Validity Checking. Multidimensional Arrays. Defining Character Arrays. Operations on Character Arrays. String Functions and Memory Corruption. Two-Dimensional Character Arrays. Array Overflow in Insertion Algorithms. Defining Array Types. Structures as Heterogeneous Aggregates. Defining Structures as Programmer-Defined Types. Creating and Initializing Structure Variables. Hierarchical Structures and Their Components. Operations on Structure Variables. Defining Structures in Multifile Programs. Unions, Enumerations, and Bit Fields. Unions. Enumerations. Bit Fields.
6. Memory Management: The Stack and the Heap. Name Scope as a Tool for Cooperation. C++ Lexical Scopes. Name Conflicts Within the Same Scope. Using Same Names in Independent Scopes. Using Same Name in Nested Scopes. Scope of Loop Variables. Memory Management: Storage Classes. Automatic Variables. External Variables. Static Variables. Memory Management: Using Heap. C++ Pointers as Typed Variables. Allocating Memory on the Heap. Arrays and Pointers. Dynamic Arrays. Dynamic Structures. Input and Output with Disk Files. Output to File. Input from File. Input/Output File Objects.
II. OBJECT-ORIENTED PROGRAMMING WITH C++.
7. Programming with C++ Functions. C++ Functions as Modularization Tools. Function Declarations. Function Definitions. Function Calls. Argument Promotions and Conversions. Parameter Passing in C++. Calling by Value. Calling by Pointer. Parameter Passing in C++: Calling by Reference. Structures. Arrays. More on Type Conversions. Returning a Value from a Function. Inline Functions. Parameters With Default Values. Function Name Overloading.
8. Object-Oriented Programming with Functions. Cohesion. Coupling. Implicit Coupling. Explicit Coupling. How to Reduce the Intensity of Coupling. Data Encapsulation. Information Hiding. A Larger Example of Encapsulation. Shortcomings of Encapsulation with Functions.
9. C++ Class as a Unit of Modularization. Basic Class Syntax. Binding Together Data and Operations. Elimination of Name Conflicts. Implementing Member Functions Outside of Class. Defining Class Objects of Different Storage Classes. Controlling Access to Class Members. Initialization of Object Instances. Constructors as Member Functions. Default Constructors. Copy Constructors. Conversion Constructors. Destructors. Timing of Constructor and Destructor Invocations. Class Scope and the Overriding of Names in Nested Scopes. Memory Management with Operators and Function Calls. Using Returned Objects in Client Code. Returning Pointers and References. Returning Objects. More on the const Keyword. Static Class Members. Using Global Variables as Class Characteristics. The Fourth Meaning of the static Keyword. Initialization of Static Data Members. Static Member Functions.
10. Operator Functions: Another Good Idea. Overloading of Operators. Limitations on Operator Overloading. What Operators Cannot Be Overloaded. Limitations on Return Types. Limitations on the Number of Parameters. Limitations on Operator Precedence. Overloaded Operators as Class Members. Replacing a Global Function with a Class Member. Using Class Members for Chain Operations. Using the const Keyword. Case Study: Rational Numbers. Mixed Types as Parameters. Friend Functions.
11. Constructors and Destructors: Potential Trouble. More on Passing Objects by Value. Operator Overloading for Nonnumeric Classes. The String Class. Dynamic Management of Heap Memory. Protecting Object Heap Data from Client Code. Overloaded Concatenation Operator. Preventing Memory Leaks. Protecting Program Integrity. How to Get There from Here. More on the Copy Constructor. Remedies for the Integrity Problem. Copy Semantics and Value Semantics. Programmer-Defined Copy Constructor. Return by Value. Limits for Copy Constructor Effectiveness. Overloading the Assignment Operator. Problems with System-Supplied Assignment Operator. Overloaded Assignment: The First Version (Memory Leak). Overloaded Assignment: The Next Version (Self-Assignment). Overloaded Assignment: Another Version (Chain Expression). Performance Considerations. First Remedy: More Overloading. Second Remedy: Return by Reference. Practical Considerations: What to Implement.
III. OBJECT-ORIENTED PROGRAMMING WITH AGGREGATION AND INHERITANCE.
12. Composite Classes: Pitfalls and Advantages. Using Class Objects as Data Members. C++ Syntax for Class Composition. Access to Data Members of Class Data Members. Access to Data Members of Method Parameters. Initialization of Composite Objects. Using the Components' Default Constructors. Using the Member Initialization List. Data Members with Special Properties. Constant Data Members. Reference Data Members. Using Objects as Data Members of Their Own Class. Using a Static Data Member as a Member of Its Own Class. Container Classes. Nested Classes. Friend Classes.
13. Similar Classes: How to Treat Them. Treating Similar Classes. Merging Subclass Features into One Class. Pushing Responsibility for Program Integrity to the Server. Separate Classes for Each Kind of Server Object. Using C++ Inheritance to Link Related Classes. Syntax of C++ Inheritance. Different Modes of Derivation from the Base Class. Defining and Using Objects of Base and Derived Classes. Accessing Base and Derived Class Services. Accessing Base Components of a Derived Class Object. Public Inheritance. Protected Inheritance. Private Inheritance. Adjusting Access to Base Members in the Derived Class. Default Inheritance Mode. Scope Rules and Name Resolution Under Inheritance. Name Overloading and Name Hiding. Calling a Base Method Hidden by the Derived Class. Using Inheritance for Program Evolution. Constructors and Destructors for Derived Classes. Using Initialization Lists in Derived Class Constructors. Destructors Under Inheritance.
14. Choosing between Inheritance and Composition. Choosing a Technique for Code Reuse. Example of a Client-Server Relationship between Classes. Reuse Through Human Intelligence: Just Do It Again. Reuse through Buying Services. Code Reuse Through Inheritance. Inheritance with Redefined Functions. Pluses and Minuses of Inheritance and Composition. Unified Modeling Language. The Goals of Using UML. Basic UML: Notation for Classes. Basic UML: Notation for Relationships. Basic UML: Notation for Aggregation and Generalization. Basic UML: Notation for Multiplicity. Case Study: A Rental Store. Classes and Their Associations. On Class Visibility and Division of Responsibilities. Class Visibility and Class Relationships. Pushing Responsibilities to Server Classes. Using Inheritance.
IV. ADVANCED USES OF C++.
15. Virtual Functions and Other Advanced Uses of Inheritance. Conversions between Nonrelated Classes. Strong Typing and Weak Typing. Conversion Constructors. Casts between Pointers (or References). Conversion Operators. Conversions between Classes Related Through Inheritance. Safe and Unsafe Conversions. Conversions of Pointers and References to Objects. Conversions of Pointer and Reference Arguments. Virtual Functions: Yet Another New Idea. Dynamic Binding: Traditional Approach. Dynamic Binding: Object-Oriented Approach. Dynamic Binding: Virtual Functions. Dynamic and Static Binding. Pure Virtual Functions. Virtual Functions: Destructors. Multiple Inheritance: Several Base Classes. Multiple Inheritance: Access Rules. Conversions between Classes. Multiple Inheritance: Constructors and Destructors. Multiple Inheritance: Ambiguities. Multiple Inheritance: Directed Graph. Multiple Inheritance: Is It Useful?
16. Advanced Uses of Operator Overloading. Operator Overloading: A Brief Overview. Unary Operators. Increment and Decrement Operators. Postfix Overloaded Operators. Conversion Operators. Subscript and Function Call Operators. The Subscript Operator. Function Call Operator. Input/Output Operators. Overloading Operator >>. Overloading Operator <<.
17. Templates: Yet Another Design Tool. A Simple Example of a Class Design Reuse. Syntax of Template Class Definition. Template Class Specification. Template Instantiation. Implementing Template Functions. Nested Templates. Template Classes with Several Parameters. Several Type Parameters. Templates with Constant Expression Parameters. Relations between Instantiations of Template Classes. Template Classes as Friends. Nested Template Classes. Templates with Static Members. Template Specializations. Template Functions.
18. Programming with Exceptions. A Simple Example of Exception Processing. Syntax of C++ Exceptions. Throwing an Exception. Catching an Exception. Claiming an Exception. Rethrowing an Exception. Exceptions with Class Objects. Syntax of Throwing, Claiming, and Catching Objects. Using Inheritance with Exceptions. Standard Library Exceptions. Type Cast Operators. The static_cast Operator. The reinterpret_cast Operator. The const_cast Operator. The dynamic_cast Operator. The typeid Operator.
19. What We Have Learned. C++ as a Traditional Programming Language. C++ Built-in Data Types. C++ Expressions. C++ Control Flow. C++ as a Modular Language. C++ Aggregate Types: Arrays. C++ Aggregate Types: Structures, Unions, Enumerations. C++ Functions as Modularization Tools. C++ Functions: Parameter Passing. Scope and Storage Class in C++. C++ as an Object-Oriented Language. C++ Classes. Constructors, Destructors, and Overloaded Operators. Class Composition and Inheritance. Virtual Functions and Abstract Classes. Templates. Exceptions. C++ and Competition. C++ and Older Languages. C++ and Virtual Basic. C++ and C. C++ and Java.
Index.