Chapter 1:Basic C++ Programming 1
1.1:How to Write a C++ Program 1
1.2:Defining and Initializing a Data Object 7
1.3:Writing Expressions 10
1.4:Writing Conditional and Loop Statements 15
1.5:How to UseArrays and Vectors 22
1.6:Pointers Allow for Flexibility 26
1.7:Writing and Reading Files 30
Chapter 2:Procedural Programming 35
2.1:How to Write a Function 35
2.2:Invoking a Function 41
2.3:Providing Default Parameter Values 50
2.4:Using Local Static Objects 53
2.5:Declaring a Function Inline 55
2.6:Providing Overloaded Functions 56
2.7:Defining and Using Template Functions 58
2.8:Pointers to FunctionsAdd Flexiblity 60
2.9:Setting Up a Header File 63
Chapter 3:Generic Programming 67
3.1:The Arithrnetic of Pointers 68
3.2:Making Sense of Iterators 73
3.3:Operations Common to All Containers 76
3.4:Using the Sequential Containers 77
3.5:Using the Generic Algorithms 81
3.6:How to Design a Generic Algorithm 83
3.7:Using a Map 90
3.8:Using a Set 91
3.9:How to Use Iterator Inserters 93
3.10:Using the iostream Iterators 95
Chapter 4:Object-Based Programming 99
4.1:How to Implement a Class 100
4.2:What Are Class Constructors and the Class Destructor? 104
4.3:What Are mutable and const? 109
4.4:What Is the this Pointer? 113
4.5:Static Class Members 115
4.6:Building an Iterator Class 118
4.7:Collaboration Sometimes Requires Friendship 123
4.8:Implementing a Copy Assignment Operator 125
4.9:Implementing a Function Object 126
4.10:Providing Class Instances of the iostrearn Operators 128
4.11:Pointers to Class Member Functions 130
Chapter 5:Object-Oriented Programming 135
5.1:Object-Oriented Programming Concepts 135
5.2:ATour of Object-Oriented Programming 138
5.3:Polymorphism without Inheritance 142
5.4:Defining an Abstract Base Class 145
5.5:Defining a Derived Class 148
5.6:Using an Inheritance Hierarchy 155
5.7:How Abstract Should a Base Class Be? 157
5.8:Initialization,Destruction,and Copy 158
5.9:Defining a Derived Class Virtual Function 160
5.10:Run-Time Type Identification 164
Chapter 6:Programming with Templates 167
6.1:Parameterized Types 169
6.2:The Template Class Definition 171
6.3:Handling Template Type Parameters 172
6.4:Implementing the Template Class 174
6.5:AFunction Template Output Operator 180
6.6:Constant Expressions and Default Parameters 181
6.7:Template Parameters as Strategy 185
6.8:Member Template Functions 187
Chapter 7:Exception Handling 191
7.1:Throwing an Exception 191
7.2:Catching an Exception 193
7.3:Trying for an Exception 194
7.4:Local Resource Management 198
7.5:The Standard Exceptions 200
Appendix A:Exercise Solutions 205
Appendix B:Generic Algorithms Handbook 255
Index 271
注释 277