当前位置:首页 > 工业技术
C++程序设计教程  第2版
C++程序设计教程  第2版

C++程序设计教程 第2版PDF电子书下载

工业技术

  • 电子书积分:17 积分如何计算积分?
  • 作 者:钱能著
  • 出 版 社:北京:清华大学出版社
  • 出版年份:2005
  • ISBN:7302114641
  • 页数:551 页
图书介绍:本书讲述C++的编程方法,在结构上自成体系,还从学术角度,阐述对C++的独到见解,洞穿C++内部实现要害,直击抽象编程本质,并有大量编程实例供参考。
《C++程序设计教程 第2版》目录

第一部分 基础编程(Part Ⅰ The Basic Programming) 2

第1章 概述(Introduction) 2

1.1 程序设计语言(Programming Language) 2

目录 2

1.2 C++前史(The Origins and History ofC++) 4

1.3 C++ 5

1.3.1 褒贬C(Comment on C) 5

1.3.2 C继承者(Inheritor ofC) 6

1.3.3 标准C++(Standard C++) 7

1.4.1 编程过程(Programming Procedure) 8

4.4.3 逻辑推演(Logic Inference Deduction) 11 8

1.4 C++编程流程(C++Programming Flow) 8

1.4.2 最小样板程序(Minimum Sample Program) 9

1.4.3 编程风格(Programming Style) 10

1.5 程序与算法(Programs Algorithms) 11

1.5.1 程序(Programs) 11

1.5.2 算法(Algorithms) 11

1.5.3 编程与结构(Programming Structures) 12

1.6 过程化程序设计(Procedural Programming) 13

1.6.1 基于过程的程序设计(Procedure-Based Programming) 13

1.6.2 结构化程序设计(Structured Programming) 16

1.7 对象化程序设计(Objectified Programming) 17

1.7.1 基于对象的程序设计(Object-Based Programming) 17

1.7.2 面向对象的程序设计(Object-Oriented Programming) 20

1.8 目的归纳(Conclusion) 21

1.9 练习1(Exercises 1) 23

第2章 基本编程语句(Basic Programming Statements) 24

2.1 说明语句(Declarative Statements) 24

2.1.1 变量定义(Variable Definition) 25

2.1.2 函数声明和定义(Function Declaration Definition) 26

2.2.1 if语句(if Statement) 27

2.2 条件语句(Conditional Statements) 27

2.1.3 初始化与赋值(Initializing Assignment) 27

2.2.2 条件表达式(Conditional Expressions) 30

2.2.3 switch语句(switch Statement) 31

2.3.1 for循环结构(for Loop Structure) 34

2.3 循环语句(Loop Statements) 34

2.2.4 if或switch语句(if or switch) 34

2.3.2 for循环(for Loop) 36

2.3.3 while循环(while Loop) 37

2.3.4 do-while循环(do-while Loop) 39

2.4 循环设计(Loop Designs) 40

2.4.1 字符图形(Character Graphics) 40

2.4.2 素数判定(Prime Decision) 44

2.5 输入输出语句(I/O Statements) 45

2.5.1 标准I/O流(Standard I/O Stream) 45

2.5.2 流状态(Stream States) 46

2.5.3 文件流(File Streams) 48

2.6 转移语句(Move Statements) 51

2.6.2 continue语句(continue Statement) 51

2.6.1 break语句(break Statement) 51

2.6.3 goto语句(goto Statement) 53

2.7 再做循环设计(More Loop Designs) 55

2.7.1 逻辑判断(Logic Decision) 55

2.7.2 级数逼近(Progression Approximation) 57

2.8 目的归纳(Conclusion) 60

2.9 练习2(Exercises 2) 61

第3章 数据类型(Data Types) 64

3.1 整型(int Types) 65

3.1.1 二进制补码(Binary Complement) 65

3.1.2 整型数表示范围(int Range) 67

3.1.4 整数字面值(IntegerLiterals) 68

3.1.3 编译器与整数长度(Compiler int Length) 68

3.1.5 整数算术运算(Integer Arithmetic Operations) 69

3.2 整数子类(int Subtypes) 70

3.2.1 字符型(charType) 70

3.2.2 枚举型(enum Type) 71

3.2.3 布尔型(bool Type) 72

3.3 浮点型(float Type) 72

3.3.1 浮点数表示(Floating-Point Number Representation) 72

3.3.2 浮点型表示范围(float Type Ranges) 76

3.4 C-串与string(C-strings string) 77

3.4.1 C-串(C-strings) 77

3.4.2 字符指针与字符数组(charPointers charArrays) 77

3.4.3 string 80

3.4.4 string与C-串的输入输出(string C-stringI/O) 81

3.4.5 string流(string Streams) 82

3.5 数组(Arrays) 83

3.5.1 元素个数(Number ofElements) 83

3.5.2 初始化(Initialization) 84

3.5.3 默认值(DefaultValues) 85

3.5.4 二维数组(2-D Arrays) 86

3.6 向量(Vectors) 87

3.6.1 基本操作(Basic Operations) 87

3.6.2 添加元素(Adding Elements) 88

3.6.3 二维向量(2-D Vectors) 89

3.7 指针与引用(Pointers References) 91

3.7.1 指针(Pointers) 91

3.7.2 指针的类型(Pointer Types) 93

3.7.3 指针运算(PointerOperations) 95

3.7.4 指针限定(Pointers Restrictions) 97

3.7.5 引用(Reference) 98

3.9 练习3(Exercises 3) 100

3.8 目的归纳(Conclusion) 100

4.1 名词解释与操作符(Name Explanation Operators) 103

4.1.1 名词解释(Some Name Explanations) 103

第4章 计算表达(Computation Expressing) 103

4.1.2 操作符汇总(Operators Summary) 105

4.1.3 操作符的说明(OperatorExpanations) 105

4.2 算术运算问题(Arithmetic Problems) 106

4.2.1 周而复始的整数(int:Move in Cycles) 106

4.2.2 算法局限性(Algorithm Limitation) 107

4.2.3 中间结果溢出(Intermediate Result Overflow) 108

4.2.4 浮点数的比较(Floating-Point Number Comparison) 109

4.3 相容类型的转换(Cast CompatibleTypes) 111

4.3.1 隐式转换(ImplicitCast) 111

4.3.2 精度丢失(Lost Precision) 112

4.3.3 显式转换(Explicit Cast) 113

4.4 关系与逻辑操作(Relations Logic Operations) 114

4.4.1 条件表达(Condition Expressing) 115

4.4.2 基本逻辑与短路求值(Basic Logic Short-Circuit Evaluation) 117

4.5 位操作(Bit Operations) 119

4.5.1 位操作种类(The Kinds ofBit Operations) 119

4.5.2 位操作实例(Bit Operation Example) 120

4.6 增量操作(Increment Operations) 122

4.6.1 增量操作符(Increment Operator) 122

4.6.2 操作符识别(Operator Recognition) 123

4.6.3 指针的增量操作(Pointer Increment Operation) 124

4.7 表达式的副作用(Expression's Side Effects) 125

4.7.1 操作数求值顺序(Operands Evaluating Order) 125

4.7.2 编译器相关(Complier Correlated) 126

4.7.3 交换律失效(Commutation Law Invalidation) 127

4.7.4 括号失效(Bracket Invalidation) 127

4.8 目的归纳(Conclusion) 128

4.7.5 消除副作用(Avoiding Side Effects) 128

4.9 练习4(Exercises 4) 129

第二部分 过程化编程(Part Ⅱ The Procedural Programming) 134

第5章 函数机制(Function Mechanism) 134

5.1 函数性质(Function Character) 134

5.1.1 函数的形态(The Function Forms) 134

5.1.2 函数黑盒(Function Blackbox) 136

5.1.3 传值参数(Value-Passed Parameters) 137

5.2 指针参数(Pointer Parameters) 139

5.2.1 指针和引用参数(Pointer Reference Parameters) 139

5.2.2 函数的副作用(Function's Side Effect) 142

5.3 栈机制(The Stack Mechanism) 145

5.3.1 运行时内存布局(Runtime Memory Layout) 145

5.3.2 栈区(The Stack Area) 145

5.3.3 局部数据的不确定性(Uncertainty ofLocal Data) 148

5.3.4 指针作祟(The Menacing Pointers) 149

5.4 函数指针(Function Pointers) 150

5.4.1 指向函数的指针(Function Pointers) 151

5.4.2 函数指针参数(Function Pointer Parameters) 152

5.4.3 函数指针数组(Function Pointer Arrays) 154

5.4.4 简略函数指针表示(The Outline ofFunction Pointers) 155

5.4.5 函数指针的意义(The Sense ofFunction Pointers) 156

5.5 main函数参数(The main's Arguments) 157

5.5.1 命令行重定向(Redirecting Command Line) 157

5.5.2 使用main参数(Using main Arguments) 158

5.6 递归函数(Recursive Functions) 161

5.6.1 递归本质(Essence ofRecursions) 161

5.6.2 递归条件(Condition ofRecursions) 163

5.6.3 消去递归(Removing Recursions) 164

5.6.4 递归评说(Comment on Recursions) 164

5.7.1 重载概念(Concept ofFunction Overload) 165

5.7 函数重载(Function Overload) 165

5.7.2 重载函数匹配(Overloaded Function Call Matches) 166

5.7.3 重载技术(Function Overload Technology) 167

5.7.4 默认参数(Default Parameters) 168

5.7.5 默认参数规则(Default Parameter Rules) 169

5.7.6 无名参数(Nameless Parameters) 170

5.7.7 重载或参数默认(Overload or Parameter Default) 170

5.8 目的归纳(Conclusion) 172

5.9 练习5(Exercises 5) 173

第6章 性能(Performance) 176

6.1 内联函数(Inline Functions) 177

6.1.1 概念(Concept) 177

6.1.2 规则(Rules) 179

6.1.3 性能测试(Performance Testing) 180

6.2.2 安排车厢顺序(Arranging Carriage Order) 181

6.2.1 STL中的容器(STL Container) 181

6.2 数据结构(Data Structures) 181

6.2.3 栈法(Stack Method) 182

6.2.4 向量法(Vector Method) 184

6.3 算法(Algorithms) 185

6.3.1 算法与性能(Algorithms Performance) 185

6.3.2 Fibonacci数列算法分析(Fib's Algorithms Analyses) 185

6.3.3 选择算法(Selecting Algorithms) 188

6.4 数值计算(Numerical Computation) 189

6.4.1 求解积分问题(Solving Integral Problems) 189

6.4.2 矩形法(Rectangle Method) 190

6.4.3 辛普生法(Simpson Method) 191

6.5 标准C++算法(Standard C++Algorithms) 194

6.5.1 集合元素访问(Element Access ofset) 194

6.5.2 判断字串相等1(Judging String Equal 1) 194

6.5.3 判断字串相等2(Judging String Equal 2 ) 195

6.5.4 判断字串相等3(Judging String Equal 3) 196

6.5.5 剩余串排列1(Arranging Remained String 1) 197

6.5.6 剩余串排列2(Arranging Remained String 2) 198

6.6 动态内存(Dynamic Memory) 199

6.6.1 预留向量空间(Reserving Vector Space) 199

6.6.2 蛮做素数判断(Judging Prime Foolhardily) 200

6.6.3 空间换时间(Trade Space forTime) 201

6.7 低级编程(Lower Programming) 202

6.7.1 C编程(C Programming) 202

6.7.2 低级筛法(Lower Sieve Solution) 204

6.7.3 筛法性能的比较(Comparing Sieves Performance) 206

6.8 目的归纳(Conclusion) 207

6.9 练习6(Exercises 6) 209

7.1 函数组织(Function Organization) 214

7.1.1 程序构成(Program Composition) 214

第7章 程序结构(Program Structure) 214

7.1.2 程序文件拆分(Split up Program File) 216

7.2 头文件(HeaderFiles) 217

7.2.1 原始头文件(Original HeaderFile) 217

7.2.2 界面头文件(Header File as Interface) 219

7.2.3 头文件的内容(Content ofHeader File) 220

7.3 全局数据(Global Data) 221

7.3.1 全局数据访问(Global Data Access) 221

7.3.2 消除全局数据(Removing Global Data) 223

7.3.3 一次定义原则(One-Definition Rule) 224

7.3.4 全局常量(Global Constant) 227

7.4 静态数据(Static Data) 229

7.4.1 静态全局数据(Static Global Data) 229

7.4.2 静态局部数据(Static Local Data) 231

7.5 作用域与生命期(Scopes Lifetime) 232

7.5.1 作用域(Scopes) 232

7.5.2 生命期(LifeTime) 235

7.6 名空间(Namespace) 236

7.6.1 名空间的概念(Namespace Concept) 236

7.6.2 名空间的组织(Namespace Organization) 237

7.6.3 组织模块(Module Organization) 239

7.6.4 数据名冲突(Data Name Clash) 242

7.6.5 名空间的用法(Using namespace) 243

7.7 预编译(Pre-Compilation) 244

7.7.1 #include指令(#include) 244

7.7.2 条件编译指令(Condition Compiling Directive) 245

7.7.3 头文件卫士(Header File Safeguard) 246

7.7.4 #define指令(#define) 246

7.8 目的归纳(Conclusion) 247

7.9 练习7(Exercises 7) 248

8.1.1 定义结构(Defining Structure) 252

8.1 从结构到类(From Structure to Class) 252

第8章 类(Classes) 252

第三部分 面向对象编程技术(Part Ⅲ The Object-Oriented Programming) 252

8.1.2 定义类(Defining Class) 255

8.2 成员函数(Member Functions) 257

8.2.1 成员函数定义(Member Function Definition) 257

8.2.2 使用对象指针(Using Object Pointer) 259

8.2.3 常成员函数(Const Member Functions) 260

8.2.4 重载成员函数(Overloading Member Functions) 261

8.3 操作符(Operators) 262

8.3.1 函数重载特征(Function Overloading Features) 262

8.3.2 性质(Character) 264

8.3.3 值返回与引用返回(Returning Values or References) 265

8.3.4 增量操作符(Increment Operators) 266

8.3.5 成员操作符(Member Operators) 267

8.4 再论程序结构(Program Structure Restatement) 269

8.4.1 访问控制(Access Controls) 269

8.4.2 类的程序结构(Program Structure with Classes) 270

8.4.3 类作用域(Class Scope) 272

8.5 屏蔽类的实现(Shield Class Implementations) 273

8.5.1 意义(Significance) 273

8.5.2 影响编程方法(Affecting Programming Method) 276

8.5.3 影响语言设计(Affecting Language Designing) 277

8.6 静态成员(Static Members) 277

8.6.1 静态数据成员(Static Data Members) 277

8.6.2 静态成员函数(Static Member Functions) 280

8.7 友元(Friends) 281

8.7.1 频繁调用问题(Frequent Calling Problems) 281

8.7.2 提高访问性能(Improving Access Performance) 284

8.7.3 其他特征(Other Features) 286

8.8 目的归纳(Conclusion) 288

8.9 练习8(Exercises 8) 288

9.1.1 初始化要求(Initialization Requirement) 293

第9章 对象生灭(Object Birth Death) 293

9.1 构造函数设计(Constructor Design) 293

9.1.2 封装性要求(Encapsulation Requirement) 294

9.1.3 函数形式(Function Form) 295

9.1.4 无返回值(Non Return-Type) 296

9.1.5 set的缺憾(Disfigurement of set) 296

9.1.6 一次性对象(Only-One-Time Object) 298

9.2 构造函数的重载(Constructor Overload) 298

9.2.1 重载构造函数(Overload Constructor) 298

9.2.2 无参构造函数(Non-Parameter Constructor) 301

9.3 类成员初始化(Class Member Initialization) 302

9.3.1 默认调用的无参构造函数(Default Calling Non-Parameter Constructor) 302

9.3.2 初始化的困惑(Initialization Puzzle Dom) 304

9.3.3 成员的初始化(Initializing Members) 305

9.4.1 局部对象(Local Objects) 307

9.4 构造顺序(Constructing Order) 307

9.4.2 全局对象(Global Objects) 308

9.4.3 成员对象(Member Objects) 309

9.4.4 构造位置(Constructing Position) 310

9.5 拷贝构造函数(Copy Constructor) 311

9.5.1 对象本体与实体(Object Realty Entity) 311

9.5.2 默认拷贝构造函数(Default Copy Constructor) 313

9.5.3 自定义拷贝构造函数(User-Defined Copy Constructor) 315

9.6 析构函数(Destructors) 316

9.7 对象转型与赋值(Object Conversion Assignment) 318

9.7.1 用于转型的构造函数(Constructor Used as Type Conversion) 318

9.7.2 对象赋值(Object Assignment) 320

9.8 目的归纳(Conclusion) 322

9.9 练习9(Exercises 9) 323

10.1.1 类层次结构(Class Hierarchy Structure) 327

10.1 继承结构(Inheritance Structure) 327

第10章 继承(Inheritance) 327

10.1.2 派生类对象结构(Derived Object Structure) 329

10.2 访问父类成员(Access Father's Member) 330

10.2.1 继承父类成员(Inherit Father's Member) 330

10.2.2 类内访问控制(Access Control in Class) 332

10.3 派生类的构造(Constructing Derived Classes) 334

10.3.1 默认构造(Default Construction) 334

10.3.2 自定义构造(User-Defined Construction) 334

10.3.3 拷贝构造与赋值(Copy Construction Assignment) 336

10.3.4 对象构造顺序(Object Constructing Order) 336

10.4 继承方式(Inheritance Mode) 337

10.4.1 继承访问控制(Inheriting Access Control) 337

10.4.2 调整访问控制(Adjusting Access Control) 340

10.5 继承与组合(Inheritance Composition) 341

10.5.1 对象结构(Object Structure) 341

10.5.2 性质差异(Character Differentiation) 341

10.5.3 对象分析(Object Analysis) 342

10.5.4 继承设计(Inheritance Design) 344

10.5.5 组合设计(Composition Design) 345

10.6 多继承概念(Multi-Inheritance Concept) 347

10.6.1 多继承结构(Multi-Inheritance Structure) 347

10.6.2 基类成员名冲突(Base-Class Member Name Collision) 348

10.6.3 基类分解(Base-Class Decomposition) 349

10.7 多继承技术(Multi-Inheritance Technology) 350

10.7.1 虚拟继承(Virtual Inheritance) 350

10.7.2 多继承对象构造顺序(Multi-Inheritance Object Constructing Order) 352

10.7.3 多继承评价(Multi-Inheritance Evaluation) 352

10.8 目的归纳(Conclusion) 353

10.9 练习10(Exercises 10) 354

第11章 基于对象编程(Object-Based Programming) 356

11.1.1 行为抽象(Action Abstract) 357

11.1 抽象编程(Abstract Programming) 357

11.1.2 数据抽象(Data Abstract) 358

11.1.3 数据结构(Data Structure) 359

11.2 编程质量(Programming Quality) 360

11.2.1 可读性(Readability) 360

11.2.2 易编程性(Programability) 361

11.2.3 安全性(Safety) 362

11.2.4 可维护性(Maintainability) 362

11.2.5 可扩充性(Extensibility) 363

11.2.6 效率(Efficiency) 363

11.3 分析Josephus问题(Analysis the Josephus Problem) 365

11.3.1 问题描述(Problem Description) 365

11.3.2 过程化分析(Procedure Analysis) 365

11.3.3 基于对象的分析(Object-Based Analysis) 367

11.4 基于过程的解决方案(Procedure-Based Solution) 368

11.4.1 算法(The Algorithm) 368

11.4.2 算法解释(Algorithm Explanation) 369

11.4.3 算法实现(Algorithm Implementation) 370

11.5 基于对象的解决方案(Object-Based Solution) 372

11.5.1 算法(The Algorithm) 372

11.5.2 算法解释(Algorithm Explanation) 373

11.5.3 算法实现(Algorithm Implementation) 375

11.5.4 程序解释(Program Explanation) 378

11.6 程序维护(Program Maintenance) 379

11.7 程序扩展(Program Extension) 381

11.8 目的归纳(Conclusion) 384

11.9 练习11(Exercises 11) 385

第四部分 高级编程(Part Ⅳ The Advanced Programming) 388

第12章 多态(Polymorphism) 388

12.1 继承召唤多态(Inheritance Summon up Polymorphism) 388

12.1.1 祖孙互易的说明(Explaining Up Down Exchanging) 388

12.1.2 覆盖父类操作(Overlapping Superclass Operation) 389

12.1.3 同化效应(Assimilation Effect) 391

12.1.4 渴望多态(Thirsting for Polymorphism) 392

12.2 抽象编程的困惑(Abstract Programming Perplexity) 393

12.2.1 类型域方案(Type Fields Scheme) 393

12.2.2 破坏抽象编程(Destroy Abstract Programming) 395

12.2.3 渴望内在的多态(Thirsting for Inner Polymorphism) 396

12.3 虚函数(Virtual Function) 396

12.3.1 多态条件(Polymorphism Condition) 396

12.3.2 虚函数机理(Virtual Function Mechanism) 397

12.3.3 面向对象的真意(Object-Oriented Intendment) 398

12.3.4 虚函数的传播(Spreading Virtual Functions) 399

12.4 避免虚函数误用(Avoiding Misuse ofVirtual Function) 400

12.4.1 搞清重载与覆盖(Making Clear on Overload Overlap) 400

12.4.2 返回类型的例外(Exception ofReturn Type) 401

12.4.3 若干限制(Restrictions) 403

12.5.1 孤立的类(Isolated Classes) 404

12.5 精简共性的类(Simplify Class with Generality) 404

12.5.2 减少冗余代码(Reducing Verbose Code) 407

12.5.3 改变基类殃及子类(SubClass Suffered by Modifying Base-Class) 410

12.6 多态编程(Polymorphic Programming) 410

12.6.1 共同基类方案(Shared Base-Class Scheme) 410

12.6.2 自定义链表类(User-Defined Linked List Class) 414

12.6.3 表现多态(Polymorphism Showing) 416

12.7 类型转换(Type Conversions) 417

12.7.1 动态转型(dynamic_cast) 417

12.7.2 静态转型(static_cast) 419

12.7.3 常量转型(const_cast) 420

12.8 目的归纳(Conclusion) 421

12.9 练习12(Exercises 12) 422

13.1 抽象基类(Abstract Base-Class) 424

13.1.1 无意义的基类对象(Nonsensical Base-Class Objects) 424

第13章 抽象类(Abstract Class) 424

13.1.2 纯虚函数(Pure Virtual Functions) 425

13.2 抽象类与具体类(Abstract Concrete Classes) 426

13.3 深度隔离的界面(Deeply Parted Interface) 429

13.3.1 日期的年月日版本(Year-Month-Day ofDate VER) 429

13.3.2 日期的天数版本(Day-Number ofDate VER) 430

13.3.3 应用程序界面(Application Interface) 432

13.4 抽象类做界面(Abstract Class As Interface) 434

13.4.1 抽象基类方案(The Abstract Base-Class Scheme) 434

13.4.2 抽象基类IDate(Abstract Base-Class IDate) 435

13.4.3 创建Date对象(Creating Date Objects) 436

13.4.4 子类Date(Subclass Date) 437

13.4.5 应用系统编程技术(Application Programming) 438

13.5 演绎概念设计(Deducting Concept Design) 440

13.5.1 面向对象的模块(Object-Oriented Module) 440

13.5.2 Sony类层次结构(Class Sony Hierarchy) 440

13.5.3 Sony类定义(Defining Class Sony) 442

13.5.4 CreateSony类层次结构(Class CreateSony Hierarchy) 445

13.5.5 CreateSony的子类定义(Defining Class CreateSony ) 447

13.5.6 应用系统编程技术(Application Programming ) 449

13.6 系统扩展(System Extension) 451

13.6.1 新添一个界面(Adding One Interface) 451

13.6.2 新添一种技术(Adding One Technology) 453

13.7 手柄(Handle) 455

13.7.1 对象指针问题(ObjectPointerProblem) 455

13.7.2 对象指针的外套(The Coat ofObject Pointer) 456

13.7.3 可用的手柄类(Usable Handle) 457

13.8 目的归纳(Conclusion) 459

13.9 练习13(Exercises 13) 459

第14章 模板(Templates) 461

14.1 函数模板(Function Templates) 461

14.1.1 函数重载的困惑(Function Overload Perplexity) 461

14.1.2 函数模板的定义(Defining Function Template) 462

14.1.3 函数模板的用法(Using Function Templates) 463

14.2 函数模板参数(Function Template Parameters) 465

14.2.1 苛刻的类型匹配(RigorousTypeMatch) 465

14.2.2 数据形参(Data Arguments) 466

14.2.3 常量引用型形参(const Reference Arguments) 466

14.2.4 引用型形参(Reference Arguments) 467

14.2.5 函数模板重载(Function Template Overloading) 468

14.3 类模板(Class Templates) 470

14.3.1 容器类的困惑(Container Class Perplexity) 470

14.3.2 类模板定义(Class Template Definition) 471

14.3.3 类模板的实现(Class Template Implementation) 472

14.3.4 模板类和类模板(Template Class Class Templates) 474

14.3.5 模板值参数(Template Value Parameters) 475

14.3.6 默认模板实参(Default Template Parameters) 475

14.4.1 模块实例化(Template Instantiation) 476

14.4 实例化与定做(Instantiation Specialization) 476

14.4.2 定做(Specialization) 477

14.4.3 局部定做(Partial Specialization) 480

14.5 程序组织(Program Organization) 481

14.5.1 包含方式(Inclusion Mode) 481

14.5.2 分离方式(Separation Mode) 483

14.6 模板的多态(Template Polymorphism) 486

14.6.1 动多态与静多态(Dynamic Static Polymorphism) 486

14.6.2 动多态编程(Dynamic Polymorphism Programming ) 486

14.6.3 静多态编程(Static Polymorphism Programming) 489

14.6.4 动静多态的差异(Dynamic SmtiePolymorphismDifferentiation ) 490

14.7 高级编程(Advanced Programming) 490

14.7.1 动多态设计模式(Dynamic Polymorphism Design Patterns) 490

14.7.2 静多态设计模式(Static Polymorphism Design Pattems) 492

14.7.3 泛型编程(Generic Programming) 494

14.9 练习14(Exercises14) 496

14.8 目的归纳(Conclusion) 496

第15章 异常(Exception) 498

15.1 错误处理的复杂性(Error Processing Complexity) 498

15.1.1 错误种类(Kinds ofErrors) 498

15.1.2 模块的隔绝性(Isolated Modular) 499

15.1.3 调用链的牵制(Call-Link's Hold down) 500

15.2 使用异常(Using Exception) 502

15.2.1 异常使用三部曲(Three Steps on Using Exception) 503

15.2.2 退化为普通错误处理(Becoming General Error Handling ) 503

15.2.3 跨越函数的异常处理(Supario Function Exception Handling) 504

15.2.4 标准异常的用法(Using Standard Exception) 505

15.3 捕捉异常(Catching Exception) 506

15.3.1 类型匹配(Type Match) 506

15.3.2 撒网捕捉(Exception Catch Net) 508

15.4.1 申述异常(Description Exception) 511

15.4 异常的申述(Exception Description) 511

15.4.2 捉不住处理(Uncaught Handling) 514

15.5 异常继承体系(Exception Inheritance System) 515

15.5.1 异常类层次结构(Exception Class Hierarchy) 515

15.5.2 异常类层次结构的用法(Using Exception Class Hierarchy) 516

15.6 异常的应用(Exception Applications) 519

15.6.1 构造函数的错误处理(Constructor Error Processing ) 519

15.6.2 引用的动态转型(Reference dynamic cast) 521

15.6.3 typeid的用法(Using typeid) 522

15.7 非错误处理(Non-Error Processing) 523

15.7.1 另一种循环控制法(Another Loop Controlling) 523

15.7.2 递归控制法(Recursive Controlling) 525

15.8 目的归纳(Conclusion) 526

15.9 练习15(Exercises 15) 527

A.1 C++语言文法(C++Language Grammar) 532

A.2 语法图(Grammar Graph) 532

附录A语 法导读(Guide to Grammar) 532

附录(Appendices) 532

A.3 Barcus范式(Barcus Normal Form,BNF) 534

A.4 C++关键字(C++Keywords) 535

A.5 整数文法(Integer Grammar) 536

A.6 浮点数文法(Floating-Point Number Grammar) 537

A.7 编译单位(Compiling Unit) 538

附录B 标准模板库导用(Guide to Using STL) 539

B.1 仿函数与算法(Function Object Algorithm) 539

B.2 STL仿函数(STL Default Function Objects) 545

B.3 谓词(Predicates) 546

B.4 函数配接器(Function Adapters) 547

B.5 插入遍历器和流遍历器(Insert Stream Iterator) 549

附录C 参考文献(References) 550

返回顶部