Notes to the Reader 1
The Structure of This Book 1
Implementation Notes 2
Exercises 2
Design Notes 3
Historical Note 3
Efficiency and Structure 5
Philosophical Note 6
Thinking about Programming in C++ 7
RuIes of Thumb 9
Note to C Programmers 9
References 10
Chapter 1: A Tour of C++ 11
1.1 Introtluction 11
1.2 Comments 14
1.3 Types and Declarations 14
1.4 Expressions and Statements 16
1.5 Functions 21
1.6 Program Structure 22
1.7 Classes 23
1.8 Operator Overloading 25
1.9 References 26
1.10 Constructors 27
1.11 Vectors 28
1.12 Inline Expansion 29
1.13 Derived Classes 30
1.14 More about Operators 32
1.15 Friends 34
1.16 Generic Vectors 35
1.17 Polymorphic Vectors 35
1.18 Virtual Functions 37
Chapter 2: Declarations and Constants 39
2.1 Ieclarations 39
2.2 Names 44
2.3 Types 44
2.4 Constants 59
2.5 Saving Space 65
2.6 Exercises 68
Chapter 3: Expressions and Statements 71
3.1 A Desk Caloulat 71
3.2 Operator Sumrnary 84
3.3 Statement Summarv 94
3.4 Comments and Indo ntation 97
3.5 Exercises 99
Chapter 4: Functions and Files 103
4.1 Introduction 103
4.2 Linkage 104
4.3 Header Files 106
4.4 Files as Modules 114
4.5 How to Make a Library 115
4.6 Functions 116
4.7 Macros 129
4.8 Exercises 131
Chapter 5: Classes 133
5.1 Introduction and Overview 133
5.2 Classes and Members 134
5.3 Interfaces and Implementations 142
5.4 Friends and Unions 149
5.5 Constructors and Destructors 157
5.6 Exercises 166
Chapter 6: Operator Overloading 169
6.1 Introduction 169
6.2 Operator Functions 170
6.3 User-defined Type Conversion 173
6.4 Constants 177
6.5 Large Objects 177
6.6 Assignment and Initialization 178
6.7 Subscripting 181
6.8 Function Call 183
6.9 A String Class 184
6.10 Friends and Members 187
6.11 Caveat 188
6.12 Exercises 188
Chapter 7: Derived Classes 191
7.1 Introduction 191
7.2 Derived Classes 192
7.3 Alternative Intert 203
7.4 Adding to a CL 211
7.5 Heterogeneous I isrs 213
7.6 A Complete Program 213
7. Free Storc 222
7.8 E xerciscs 223
Chapter 8: Streams 225
8.1 Introduotion 225
8.2 Output 226
8.3 Files and Streams 233
8.4 Input 236
8.5 String Manipulation 241
8.6 Buffering 242
8.7 Efficiency 244
8.8 Exercises 244
Reference Manual 245
r.1 Introduction 245
r.2 Lexical Conveqtions 245
r.3 Syntax Notation 248
r.4 Names and Types 248
r.5 Objects and Lvalues 251
r.6 Conversions 252
r.7 Expressions 254
r.8 Declarations 265
r.9 Statements 292
r.10 Function Defiinitions 296
r.11 Compiler Control Lines 298
r.12 Constant Expressions 301
r.13 Portability Considerations 301
r.14 Syntax Summary 302
r.15 Differences from C 309
Index 313