内容简介
Chapter One Typographic Conventions(绪论)
1.1 What is a computer program?(什么是计算机程序?)
1.2 Developing a computer program(开发计算机程序)
1.2.1 Program development cycle
1.3 Learning C++(学习C++)
1.4 Web site for this book(本书的网站)
1.5 Brief history of C++(C++简史)
1.6 ANSI/ISO C++ standard(ANSI/ISO C++标准)
Chapter Two Beginning to Program in C++(C++编程入门)
2.1 Constants(常量)
2.2 Variables(变量)
2.3 Simple output to the screen(简单的屏幕输出)
2.4 Comments(注释)
2.5 Data types(数据类)
2.5.1 Short integer data types
2.5.2 Long integer data types
2.5.3 Boolean data types
2.5.4 Double floating-point data types
2.5.5 Unsigned integer data types
2.6 Data type sizes(数据类型的大小)
2.7 Operators(运算符)
2.7.1 The assignment operator
2.7.2 Arithmetic operators
2.7.3 Increment and decrement operators
2.7.4 Combined assignment operators
2.8 Operator precedence(运算符的优先级)
2.9 Data type conversions and casts(类型转换和强转)
Programming pitfalls
Quick syntax reference
Exercises
Chapter Three Keyboard Input and Screen Output(键盘输入和屏幕输出)
3.1 Simple keyboard input(简单的键盘输入)
3.2 Manipulators(流操纵符)
3.3 Single-character input and output(单个字符的输入和输出)
Programming pitfalls
Quick syntax reference
Exercises
Chapter Four Selection and Iteration(选择与循环)
4.1 Selection(选择)
4.1.1 The if statement
4.1.2 The if-else statement
4.1.3 Compound statements
4.1.4 Logical operators
4.1.5 Nested if statements
4.1.6 The switch statement
4.1.7 The conditional operator?:
4.2 Iteration(循环)
4.2.1 The while statement
4.2.2 The do-while loop
4.2.3 The for statement
4.2.4 Nested loops
Programming pitfalls
Quick syntax reference
Exercises
Chapter Five Arrays and Structures(数组和结构体)
5.1 Arrays(数组)
5.1.1 Introduction
5.1.2 Initialising an array
5.1.3 Two-dimensional arrays
5.1.4 Initialising a two-dimensional array
5.1.5 Multi-dimensional arrays
5.2 Structures(结构体)
5.2.1 Introduction
5.2.2 Declaring a structure
5.2.3 Initialising a structure variable
5.2.4 Nested structures
5.3 The typedef statement(typedef语句)
5.4 Arrays of structures(结构体数组)
5.5 Enumerated data types(枚举数据类型)
Programming pitfalls
Quick syntax reference
Exercises
Chapter Six Strings(字符串)
6.1 C-strings(C风格字符串)
6.2 C-string input and output (C风格字符串的输入和输出)
6.3 Accessing individual characters of a C-string(访问C风格字符串中的单个字符)
6.4 C-string functions (C风格字符串函数)
6.4.1 Finding the length of a C-string
6.4.2 Copying a C-string
6.4.3 C-string concatenation
6.4.4 Comparing C-strings
6.4.5 Other C-string functions
6.4.6 Converting numeric C-strings to numbers
6.5 C++ strings(C++字符串)
6.5.1 string initialisation and assignment
6.5.2 string concatenation
6.5.3 string length,string indexing and sub-strings
6.5.4 string replace,erase,insert and empty strings
6.5.5 string searching
6.5.6 string comparisons
6.5.7 string input
6.5.8 string conversions
6.6 Arrays of strings(string类型的数组)
6.7 Character classification(字符分类)
Programming pitfalls
Quick syntax reference
Exercises
Chapter Seven Functions(函数)
7.1 Introduction(引言)
7.2 Function arguments(函数实参)
7.3 Default parameter values(默认的形参值)
7.4 Returning a value from a function(从函数返回一个值)
7.5 Inline functions(内联函数)
7.6 Passing arguments by value(按值传递实参)
7.7 Passing arguments by reference(按引用传递实参)
7.8 Passing a one-dimensional array to a function(向函数传递一维数组)
7.9 Passing a multi-dimensional array to a function(向函数传递多维数组)
7.10 Passing a structure variable to a function(向函数传递结构体变量)
7.11 Passing a string to function(向函数传递字符串)
7.11.1 Passing a C++ string to a function
7.11.2 Passing a C-string to a function
7.12 Recursion(递归)
7.13 Function overloading(函数重载)
7.14 Storage classes autoand static(auto和static存储类型)
7.14.1 auto
7.14.2 static
7.15 The scope of a variable(变量的作用域)
7.15.1 Block scope
7.15.2 Global scope
7.15.3 Reusing a variable name
7.16 Mathematical functions(数学函数)
7.16.1 Some trigonometric functions
7.16.2 Pseudo-random number functions
Programming pitfalls
Quick syntax reference
Exercises
Chapter Eight Objects and Classes(对象和类)
8.1 What is an object?(什么是对象?)
8.2 What is a class?(什么是类?)
8.3 Further examples of classes and objects(类和对象的更进一步的示例)
8.3.1 A student class
8.3.2 A bank account class
8.4 Abstraction(抽象)
8.5 Constructing a class in C++(用C++构造一个类)
8.6 Using a class: defining and using objects(使用类:定义和使用对象)
8.7 Abstract data types(抽象数据类型)
8.8 Constructors(构造函数)
8.9 Default class constructor(默认的类构造函数)
8.10 Overloading class constructors(重载类构造函数)
8.11 Constructor initialisation lists(构造函数初始化列表)
8.12 Default argument values in a constructor(构造函数中的默认实参值)
8.13 stat ic class data members(静态类数据成员)
8.14 Using return in a member function(在成员函数中使用return)
8.15 Inline class member functions(内联成员函数)
8.16 Class interface and class implementation(类的接口和类的实现)
8.16.1 Separation of class interface and class implementation
8.16.2 Use of namespaces in header files
Programming pitfalls
Quick syntax reference
Exercises
Chapter Nine Pointers and Dynamic Memory(指针和动态内存分配)
9.1 Variable addresses(变量的地址)
9.2 Pointer variables(指针变量)
9.3 The dereference operator*(解引用运算符*)
9.4 Using cons t with pointers(使用const修饰指针变量)
9.5 Pointers and one-dimensional arrays(指针和一维数组)
9.6 Pointers and multi-dimensional arrays(指针和多维数组)
9.7 Pointers to structures(指向结构体的指针)
9.8 Pointers to class objects(指向类对象的指针)
9.9 Pointers as function arguments(指针变量作为函数实参)
9.10 Dynamic memory allocation(动态内存分配)
9.10.1 Allocating memory dynamically for an array
9.10.2 Initialisation with new
9.10.3 Allocating memory for multi-dimensional arrays
9.10.4 Out of memory error
Programming pitfalls
Quick syntax reference
Exercises
Chapter Ten Operator Overloading(运算符重载)
10.1 The need for operator overloading(运算符重载的必要性)
10.2 Overloading the addition operator+(重载加法运算符+)
10.3 Rules of operator overloading(运算符重载的规则)
10.4 Overloading++(重载运算符++)
10.4.1 Overloading prefix and postfix forms of++
10.4.2 Improving the prefix++operator member function
10.5 Overloading relational operators(重载关系运算符)
10.6 Overloading(<<and>重载运算符<<和>>)
10.7 Conversion operators(转换运算符)
10.8 Use of friend functions(使用友元函数)
10.9 Overloading the assignment operator=(重载赋值运算符=)
10.9.1 A class with a pointer data member
10.9.2 Assigning one object to anothe
10.10 The copy constructor(拷贝构造函数)
10.11 Overloading the index operator[](重载下标运算符[])
Programming pitfalls
Quick syntax reference
Exercises
Chapter Eleven Inheritance(继承)
11.1 What is inheritance?(什么是继承?)
11.2 Inheritance syntax(继承语法)
11.3 Passing arguments to abase class constructor(向基类的构造函数传递实参)
11.4 Protected class members(受保护的类成员)
11.5 Types of inheritance: public,protected and private(继承的类型:public:protected和private)
11.6 Composition(组合)
11.7 Multiple inheritance(多重继承)
11.8 Virtual base classes(虚基类)
Programming pitfalls
Quick syntax reference
Exercises
Chapter Twelve Polymorphism(多态)
12.1 What is polymorphism?(什么是多态?)
12.2 Virtual functions(虚函数)
12.2.1 When to use virtual functions
12.2.2 Overriding and overloading
12.3 Abstract base classes(抽象基类)
Programming pitfalls
Quick syntax reference
Exercises
Chapter Thirteen Templates(模板)
13.1 Introduction(引言)
13.2 Function templates(函数模板)
13.3 Class templates(类模板)
Programming pitfalls
Quick syntax reference
Exercises
Chapter Fourteen Files and Streams(文件和流)
14.1 The C++ input/output class hierarchy(C++输入/输出类的层次结构)
14.2 Opening a file(打开文件)
14.3 File error checking(文件出错检查)
14.4 Single character I/O and detecting the end of a file(单字符的I/O和文件末尾的检测)
14.5 Appending data to the end of a file(向文件末尾添加数据)
14.6 Reading lines from a file(从文件中读取行)
14.7 Random access(随机存取)
14.8 Object I/O(对象I/O)
14.9 Binary I/O(二进制I/O)
14.9.1 Serial writing of objects to a binary le
14.9.2 Serial reading of objects from a binary le
14.9.3 Binary I/O as class member functions
14.9.4 Binary file random access
Programming pitfalls
Quick syntax reference
Exercises
Appendix A List of C++Keywords
Appendix B Precedence and Associativity of C++ Operators
Appendix C ASCII Character Codes
Appendix D Fundamental C++ Built-in Data tyPe
Appendix E Common iomanip Manipulators
Appendix F Escape Sequences
Appendix G The C++Preprocessor