C++程式設計教程(第3版)(競技版)-微課視頻版

《C++程式設計教程(第3版)(競技版)-微課視頻版》是清華大學出版社2020年出版圖書,作者錢能

基本介紹

  • 書名:C++程式設計教程(第3版)(競技版)-微課視頻版
  • 作者:錢能
  • 出版社:清華大學出版社
內容簡介,目錄,

內容簡介

本書是改版教材。然而從指導思想、內容結構、寫作特點等方請棄面,都以全新的面貌呈現於讀者。全書全部重新執筆,代碼全部重寫,涵蓋了基本C++編程方法的蒸詢墓擔全部技術特徵。 本書以C++標準為藍本,從過程化編程的基本描述,到對象化編程的方法展開,乃腳汗體至高級編程的實質揭示,形成一條自然流暢的主線,通俗易懂,形象風趣。

目錄

第一部分 基 礎 編 程乃匪元府
Part Ⅰ The Basic Programming 
第1章 概述(Introduction) 2
1.1 程式設計語言(Programming Language) 2
1.2 C++前史(The Prehistory of C++) 4
1.3 C++ 6
1.3.1 褒貶C(Pass Judgement on C) 6
1.3.2 C繼承者(Inheritor of C) 7
1.3.3 標準C++(Standard C++) 7
1.4 C++編程流程(C++ Programming Flow) 8
1.4.1 編程過程(Programming Procedure) 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) 12
1.5.3 編程與結構(Programming &她鑽白 Structures) 13
1.6 過程化程式設計(Procedural Programming) 13
1.6.1 基於過程的程式設計(Procedure-Based Programming) 13
1.6.2 結構化程式設計(Structured Programming) 16
1.7 對象化程式設計(Objectified
1.7.1 基於對象的程式設計(Object-Based Programming) 18
1.7.2 面向對象的程式設計(Object-Oriented Programming) 20
1.8 目的歸納(Conclusion) 22
練習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.1.3 初始化與賦值(Initializing & Assignment) 27
2.2 條件語句(Conditional Statements) 27
2.2.1 if語句(if Statement) 27
2.2.2 條件表達式(Conditional Expressions) 30
2.2.3 switch語句(switch Statement) 31
2.2.4 if或switch語句(if or switch Statement) 34
2.3 循環語句(Loop Statements) 35
2.3.1 for循環結構(for Loop Structure) 35
2.3.2 for循環(for Loop) 36
2.3.3 while循環(while Loop) 38
2.3.4 do-while循環(do-while Loop) 39
2.4 循環設計(Cycle Designs) 40
2.4.1 字元圖形(Character Graphics) 40
2.4.2 素數判定(Prime Decision) 44
2.5 輸入輸出語句(I/O Statements) 46
2.5.1 標準I/O流(Standard I/O Streams) 46
2.5.2 流狀態(Stream States) 46
2.5.3 檔案流(File Streams) 49
2.6 轉移語句(Move Statements) 51
2.6.1 break語句(break Statement) 51
2.6.2 continue語句(continue Statement) 52
2.6.3 goto語句(goto Statement) 53
2.7 再做循環設計(More Cycle Designs) 55
2.7.1 邏輯判斷(Logic Decision) 55
2.7.2 級數逼近(Progression Approximation) 58
2.8 目的歸納(Conclusion) 61
練習2(Exercises 2) 62
第3章 數據類型(Data Types) 65
3.1 整型(int Types) 66
3.1.1 二進制補碼(Binary Complement) 66
3.1.2 整型數表示範圍(int Range) 68
3.1.3 編譯器與整型長度(Compiler & int Length) 69
3.1.4 整數字面值(Integer Literals) 70
3.1.5 整數算術運算(Integer Arithmetic Operations) 70
3.2 整數子類(int Subtypes) 71
3.2.1 字元型(char Type) 71
3.2.2 枚舉型(enum Type) 72
3.2.3 布爾型(bool Type) 73
3.3 浮點型(float Type) 73
3.3.1 浮點數表示(Floating-Point Number Representation) 74
3.3.2 浮點型表示範圍 (Floating-PointType Ranges ) 77
3.4 C-串與string(C-strings & string) 78
3.4.1 C-串(C-strings) 78
3.4.2 字元指針與字元數組(char Pointers & char Arrays) 79
3.4.3 string 82
3.4.4 string與C-串的輸入輸出(string & C-string I/O) 84
3.4.5 string流(string Streams) 85
3.5 數組(Arrays) 86
3.5.1 元素個數(Number of Elements) 86
3.5.2 初始化(Initialization) 87
3.5.3 默認值(Default Values) 89
3.5.4 二維數組(2-D Arrays) 90
3.6 向量(Vectors) 90
3.6.1 基本操作(Basic Operations) 90
3.6.2 添加元素(Adding Elements) 92
3.6.3 二維向量(2-D Vectors) 93
3.7 指針與引用(Pointers & References) 94
3.7.1 指針(Pointers) 95
3.7.2 指針的類型(Pointer Types) 96
3.7.3 指針運算(Pointer Operations) 98
3.7.4 指針限定(Pointer Restrictions) 99
3.7.5 引用(References) 101
3.8 目的歸納(Conclusion) 102
練習3(Exercises 3) 103
第4章 計算表達(Computation Expressing) 105
4.1 名詞解釋與操作符(Name Explanation & Operators) 105
4.1.1 名詞解釋(Some Name Explanations) 105
4.1.2 操作符匯總(Operators Summary) 107
4.1.3 操作符的說明(Operator Explanations) 108
4.2 算術運算問題(Arithmetic Problems) 109
4.2.1 周而復始的整數(int: Move in Cycles) 109
4.2.2 算法局限性(Algorithm Limitation) 110
4.2.3 中間結果溢出(Intermediate Result Overflow) 111
4.2.4 浮點數的比較(Floating-Point Number Comparison) 112
4.3 相容類型的轉換(Cast Compatible Types) 113
4.3.1 隱式轉換(Implicit Cast) 113
4.3.2 精度丟失(Lost Precision) 114
4.3.3 顯式轉換(Explicit Cast) 115
4.4 關係與邏輯操作(Relations & Logic Operations) 117
4.4.1 條件表達(Condition Expressing) 118
4.4.2 基本邏輯與短路求值(Basic Logic & Short-Circuit Evaluation) 120
4.4.3 邏輯推演(Logic Inference & Deduction) 121
4.5 位操作(Bit Operations) 122
4.5.1 位操作種類(The Kinds of Bit Operations) 122
4.5.2 位操作實例(Bit Operation Example) 123
4.6 增量操作(Increment Operations) 125
4.6.1 增量操作符(Increment Operators) 125
4.6.2 操作符識別(Operator Recognition) 126
4.6.3 指針的增量操作(Pointer Increment Operation) 127
4.7 表達式的副作用(Expression’s Side Effects) 128
4.7.1 運算元求值順序(Operands Evaluating Order) 128
4.7.2 編譯器相關(Complier Correlated) 129
4.7.3 交換律失效(Commutation Law Invalidation) 130
4.7.4 括弧失效(Bracket Invalidation) 130
4.7.5 消除副作用(Avoiding Side Effects) 131
4.8 目的歸納(Conclusion) 131
練習4(Exercises 4) 132
第二部分 過程化編程
Part Ⅱ The Procedural Programming
第5章 函式機制(Function Mechanism) 136
5.1 函式性質(Function Character) 137
5.1.1 函式的形態(The Function Forms) 137
5.1.2 函式黑盒(Function Blackbox) 138
5.1.3 傳值參數(Value-Passed Parameters) 140
5.2 指針參數(Pointer Parameters) 141
5.2.1 指針和引用參數(Pointer & Reference Parameters) 141
5.2.2 函式的副作用(Function’s Side Effect) 145
5.3 棧機制(The Stack Mechanism) 147
5.3.1 運行時記憶體布局(Runtime Memory Layout) 147
5.3.2 棧區(The Stack Area) 148
5.3.3 局部數據的不確定性(Uncertainty of Local Data) 151
5.3.4 指針作祟(The Menacing Pointers) 151
5.4 函式指針(Function Pointers) 153
5.4.1 指向函式的指針(Function Pointers) 153
5.4.2 函式指針參數(Function Pointer Parameters) 155
5.4.3 函式指針數組(Function Pointer Arrays) 156
5.4.4 簡略函式指針表示(The Outline of Function Pointers) 158
5.4.5 函式指針的意義(The Sense of Function Pointers) 158
5.5 main函式參數(The main’s Arguments) 159
5.5.1 命令行重定向(Redirecting Command Line) 159
5.5.2 使用main參數(Using Main Arguments) 161
5.6 遞歸函式(Recursive Functions) 164
5.6.1 遞歸本質(Essence of Recursions) 164
5.6.2 遞歸條件(Condition of Recursions) 165
5.6.3 消去遞歸(Removing Recursions) 166
5.6.4 遞歸評說(Comment on Recursions) 167
5.7 函式重載(Function Overloading) 167
5.7.1 重載概念(Concept of Function Overload) 167
5.7.2 重載函式匹配(Overloaded Function Call Matches) 170
5.7.3 重載技術(Function Overload Technology) 171
5.7.4 默認參數(Default Parameters) 171
5.7.5 默認參數規則(Default Parameter Rules) 172
5.7.6 無名參數(Nameless Parameters) 173
5.7.7 重載或參數默認(Overload or Parameter Default) 173
5.8 目的歸納(Conclusion) 175
練習5(Exercises 5) 176
第6章 性能(Performance) 179
6.1 內聯函式(Inline Functions) 180
6.1.1 概念(Concept) 180
6.1.2 規則(Rules) 182
6.1.3 性能測試(Performance Testing) 183
6.2 數據結構(Data Structures) 184
6.2.1 STL中的容器(Containers in STL) 184
6.2.2 安排車廂順序(Arrange the Order of Coach) 185
6.2.3 棧法(Stack Method) 186
6.2.4 向量法(Vector Method) 187
6.3 算法(Algorithms) 188
6.3.1 算法與性能(Algorithms & Performance) 188
6.3.2 Fibonacci數列算法分析(Fib’s Algorithms Analyses) 189
6.3.3 選擇算法(Selecting Algorithms) 191
6.3.4 超越數值範圍的策略(Strategy that Exceeding Number Range) 193
6.4 數值計算(Numerical Computation) 194
6.4.1 求解積分問題(Solve the Integral Problems) 194
6.4.2 矩形法(Rectangle Method) 194
6.4.3 辛普生法(Simpson Method) 196
6.4.4 調用庫函式(Calling for the Library Function) 198
6.5 標準C++算法(Standard C++ Algorithms) 199
6.5.1 集合元素訪問(Element Access of Set) 199
6.5.2 判斷字串相等1(Determining the String is Equal 1) 199
6.5.3 判斷字串相等2(Determining the String is Equal 2) 200
6.5.4 判斷字串相等3(Determining the String is Equal 3) 201
6.5.5 剩餘串排列1(Arranging Remaining String 1) 202
6.5.6 剩餘串排列2(Arranging Remaining String 2) 203
6.6 動態記憶體(Dynamic Memory) 204
6.6.1 預留向量空間(Reserving Vector Space) 204
6.6.2 蠻做素數判斷(Judging Prime Numbers Rudely) 205
6.6.3 空間換時間(Space for Time) 206
6.7 低級編程(Low-Level Programming) 208
6.7.1 C編程(C Programming) 208
6.7.2 低級篩法(Low-Grade Sieve) 209
6.7.3 篩法性能的比較(Comparison of Sieve Performance) 211
6.8 目的歸納(Conclusion) 213
練習6(Exercises 6) 214
第7章 程式結構(Program Structure) 219
7.1 函式組織(Function Organization) 220
7.1.1 程式構成(Program Composition) 220
7.1.2 程式檔案拆分(Program File Split) 221
7.2 頭檔案(Header File) 222
7.2.1 原始頭檔案(Original Header File) 222
7.2.2 界面頭檔案(Interface Header File) 224
7.2.3 頭檔案的內容(Content of Header File) 225
7.3 全局數據(Global Data) 226
7.3.1 全局數據訪問(Global Data Access) 226
7.3.2 消除全局數據(Eliminate Global Data) 228
7.3.3 一次定義原則(One-Definition Principle) 229
7.3.4 全局常量(Global Constant) 232
7.4 靜態數據(Static Data) 234
7.4.1 靜態全局數據(Static Global Data) 234
7.4.2 靜態局部數據(Static Local Data) 236
7.5 作用域與生命期(Scopes & Lifetime) 237
7.5.1 作用域(Scopes) 237
7.5.2 生命期(Lifetime) 239
7.6 名空間(Namespace) 241
7.6.1 名空間的概念(the Concept of Namespace) 241
7.6.2 名空間的組織(Namespace Organization) 242
7.6.3 組織模組(Module Organization) 244
7.6.4 數據名衝突(Data Name Conflict) 247
7.6.5 名空間的用法(Namespace Usage) 248
7.7 預編譯(Pre-Compilation) 249
7.7.1 #include指令(#include Directive) 250
7.7.2 條件編譯指令(Conditional Compiling Directive) 250
7.7.3 頭檔案衛士(Header Guard) 251
7.7.4 #define指令(#define Directive) 252
7.8 目的歸納(Conclusion) 253
練習7(Exercises 7) 253
第三部分 面向對象編程技術
Part Ⅲ The Object-Oriented Programming
第8章 類(Classes) 258
8.1 從結構到類(From Structure to Class) 259
8.1.1 定義結構(Defining Structure) 259
8.1.2 定義類(Defining Class) 261
8.2 成員函式(Member Functions) 263
8.2.1 成員函式定義(Member Function Definition) 263
8.2.2 使用對象指針(Using Object Pointer) 265
8.2.3 常成員函式(Constant Member Functions) 266
8.2.4 重載成員函式(Overloading Member Functions) 267
8.3 操作符(Operators) 268
8.3.1 函式重載特徵(Function Overloading Charcteristics) 268
8.3.2 性質(Characters) 270
8.3.3 值返回與引用返回(Returning Value or Reference) 271
8.3.4 增量操作符(Increment Operators) 272
8.3.5 成員操作符(Member Operators) 273
8.4 再論程式結構(Revisiting Program Structure) 275
8.4.1 訪問控制(Access Controls) 275
8.4.2 類的程式結構(Class Program Structure) 277
8.4.3 類作用域(Class Scope) 278
8.5 禁止類的實現(Shielding Implementation of Class) 280
8.5.1 意義(Significance) 280
8.5.2 影響編程方法(Influence Programming Method) 283
8.5.3 影響語言設計(Affecting Language Designing) 283
8.6 靜態成員(Static Members) 284
8.6.1 靜態數據成員(Static Data Members) 284
8.6.2 靜態成員函式(Static Member Functions) 286
8.7 友元(Friends) 287
8.7.1 頻繁調用問題(Frequent Call Problems) 287
8.7.2 提高訪問性能(Improving Access Performance) 290
8.7.3 其他特徵(Other Features) 293
8.8 目的歸納(Conclusion) 294
練習8(Exercises 8) 295
第9章 對象生滅(Object Birth & Death) 299
9.1 構造函式設計(Constructor Design) 300
9.1.1 初始化要求(Initialization Requirement) 300
9.1.2 封裝性要求(Encapsulation Requirement) 301
9.1.3 函式形式(Function Form) 301
9.1.4 無返回值(Non Return-Type) 302
9.1.5 set的缺憾(Shortcomings of set) 304
2.2 條件語句(Conditional Statements) 27
2.2.1 if語句(if Statement) 27
2.2.2 條件表達式(Conditional Expressions) 30
2.2.3 switch語句(switch Statement) 31
2.2.4 if或switch語句(if or switch Statement) 34
2.3 循環語句(Loop Statements) 35
2.3.1 for循環結構(for Loop Structure) 35
2.3.2 for循環(for Loop) 36
2.3.3 while循環(while Loop) 38
2.3.4 do-while循環(do-while Loop) 39
2.4 循環設計(Cycle Designs) 40
2.4.1 字元圖形(Character Graphics) 40
2.4.2 素數判定(Prime Decision) 44
2.5 輸入輸出語句(I/O Statements) 46
2.5.1 標準I/O流(Standard I/O Streams) 46
2.5.2 流狀態(Stream States) 46
2.5.3 檔案流(File Streams) 49
2.6 轉移語句(Move Statements) 51
2.6.1 break語句(break Statement) 51
2.6.2 continue語句(continue Statement) 52
2.6.3 goto語句(goto Statement) 53
2.7 再做循環設計(More Cycle Designs) 55
2.7.1 邏輯判斷(Logic Decision) 55
2.7.2 級數逼近(Progression Approximation) 58
2.8 目的歸納(Conclusion) 61
練習2(Exercises 2) 62
第3章 數據類型(Data Types) 65
3.1 整型(int Types) 66
3.1.1 二進制補碼(Binary Complement) 66
3.1.2 整型數表示範圍(int Range) 68
3.1.3 編譯器與整型長度(Compiler & int Length) 69
3.1.4 整數字面值(Integer Literals) 70
3.1.5 整數算術運算(Integer Arithmetic Operations) 70
3.2 整數子類(int Subtypes) 71
3.2.1 字元型(char Type) 71
3.2.2 枚舉型(enum Type) 72
3.2.3 布爾型(bool Type) 73
3.3 浮點型(float Type) 73
3.3.1 浮點數表示(Floating-Point Number Representation) 74
3.3.2 浮點型表示範圍 (Floating-PointType Ranges ) 77
3.4 C-串與string(C-strings & string) 78
3.4.1 C-串(C-strings) 78
3.4.2 字元指針與字元數組(char Pointers & char Arrays) 79
3.4.3 string 82
3.4.4 string與C-串的輸入輸出(string & C-string I/O) 84
3.4.5 string流(string Streams) 85
3.5 數組(Arrays) 86
3.5.1 元素個數(Number of Elements) 86
3.5.2 初始化(Initialization) 87
3.5.3 默認值(Default Values) 89
3.5.4 二維數組(2-D Arrays) 90
3.6 向量(Vectors) 90
3.6.1 基本操作(Basic Operations) 90
3.6.2 添加元素(Adding Elements) 92
3.6.3 二維向量(2-D Vectors) 93
3.7 指針與引用(Pointers & References) 94
3.7.1 指針(Pointers) 95
3.7.2 指針的類型(Pointer Types) 96
3.7.3 指針運算(Pointer Operations) 98
3.7.4 指針限定(Pointer Restrictions) 99
3.7.5 引用(References) 101
3.8 目的歸納(Conclusion) 102
練習3(Exercises 3) 103
第4章 計算表達(Computation Expressing) 105
4.1 名詞解釋與操作符(Name Explanation & Operators) 105
4.1.1 名詞解釋(Some Name Explanations) 105
4.1.2 操作符匯總(Operators Summary) 107
4.1.3 操作符的說明(Operator Explanations) 108
4.2 算術運算問題(Arithmetic Problems) 109
4.2.1 周而復始的整數(int: Move in Cycles) 109
4.2.2 算法局限性(Algorithm Limitation) 110
4.2.3 中間結果溢出(Intermediate Result Overflow) 111
4.2.4 浮點數的比較(Floating-Point Number Comparison) 112
4.3 相容類型的轉換(Cast Compatible Types) 113
4.3.1 隱式轉換(Implicit Cast) 113
4.3.2 精度丟失(Lost Precision) 114
4.3.3 顯式轉換(Explicit Cast) 115
4.4 關係與邏輯操作(Relations & Logic Operations) 117
4.4.1 條件表達(Condition Expressing) 118
4.4.2 基本邏輯與短路求值(Basic Logic & Short-Circuit Evaluation) 120
4.4.3 邏輯推演(Logic Inference & Deduction) 121
4.5 位操作(Bit Operations) 122
4.5.1 位操作種類(The Kinds of Bit Operations) 122
4.5.2 位操作實例(Bit Operation Example) 123
4.6 增量操作(Increment Operations) 125
4.6.1 增量操作符(Increment Operators) 125
4.6.2 操作符識別(Operator Recognition) 126
4.6.3 指針的增量操作(Pointer Increment Operation) 127
4.7 表達式的副作用(Expression’s Side Effects) 128
4.7.1 運算元求值順序(Operands Evaluating Order) 128
4.7.2 編譯器相關(Complier Correlated) 129
4.7.3 交換律失效(Commutation Law Invalidation) 130
4.7.4 括弧失效(Bracket Invalidation) 130
4.7.5 消除副作用(Avoiding Side Effects) 131
4.8 目的歸納(Conclusion) 131
練習4(Exercises 4) 132
第二部分 過程化編程
Part Ⅱ The Procedural Programming
第5章 函式機制(Function Mechanism) 136
5.1 函式性質(Function Character) 137
5.1.1 函式的形態(The Function Forms) 137
5.1.2 函式黑盒(Function Blackbox) 138
5.1.3 傳值參數(Value-Passed Parameters) 140
5.2 指針參數(Pointer Parameters) 141
5.2.1 指針和引用參數(Pointer & Reference Parameters) 141
5.2.2 函式的副作用(Function’s Side Effect) 145
5.3 棧機制(The Stack Mechanism) 147
5.3.1 運行時記憶體布局(Runtime Memory Layout) 147
5.3.2 棧區(The Stack Area) 148
5.3.3 局部數據的不確定性(Uncertainty of Local Data) 151
5.3.4 指針作祟(The Menacing Pointers) 151
5.4 函式指針(Function Pointers) 153
5.4.1 指向函式的指針(Function Pointers) 153
5.4.2 函式指針參數(Function Pointer Parameters) 155
5.4.3 函式指針數組(Function Pointer Arrays) 156
5.4.4 簡略函式指針表示(The Outline of Function Pointers) 158
5.4.5 函式指針的意義(The Sense of Function Pointers) 158
5.5 main函式參數(The main’s Arguments) 159
5.5.1 命令行重定向(Redirecting Command Line) 159
5.5.2 使用main參數(Using Main Arguments) 161
5.6 遞歸函式(Recursive Functions) 164
5.6.1 遞歸本質(Essence of Recursions) 164
5.6.2 遞歸條件(Condition of Recursions) 165
5.6.3 消去遞歸(Removing Recursions) 166
5.6.4 遞歸評說(Comment on Recursions) 167
5.7 函式重載(Function Overloading) 167
5.7.1 重載概念(Concept of Function Overload) 167
5.7.2 重載函式匹配(Overloaded Function Call Matches) 170
5.7.3 重載技術(Function Overload Technology) 171
5.7.4 默認參數(Default Parameters) 171
5.7.5 默認參數規則(Default Parameter Rules) 172
5.7.6 無名參數(Nameless Parameters) 173
5.7.7 重載或參數默認(Overload or Parameter Default) 173
5.8 目的歸納(Conclusion) 175
練習5(Exercises 5) 176
第6章 性能(Performance) 179
6.1 內聯函式(Inline Functions) 180
6.1.1 概念(Concept) 180
6.1.2 規則(Rules) 182
6.1.3 性能測試(Performance Testing) 183
6.2 數據結構(Data Structures) 184
6.2.1 STL中的容器(Containers in STL) 184
6.2.2 安排車廂順序(Arrange the Order of Coach) 185
6.2.3 棧法(Stack Method) 186
6.2.4 向量法(Vector Method) 187
6.3 算法(Algorithms) 188
6.3.1 算法與性能(Algorithms & Performance) 188
6.3.2 Fibonacci數列算法分析(Fib’s Algorithms Analyses) 189
6.3.3 選擇算法(Selecting Algorithms) 191
6.3.4 超越數值範圍的策略(Strategy that Exceeding Number Range) 193
6.4 數值計算(Numerical Computation) 194
6.4.1 求解積分問題(Solve the Integral Problems) 194
6.4.2 矩形法(Rectangle Method) 194
6.4.3 辛普生法(Simpson Method) 196
6.4.4 調用庫函式(Calling for the Library Function) 198
6.5 標準C++算法(Standard C++ Algorithms) 199
6.5.1 集合元素訪問(Element Access of Set) 199
6.5.2 判斷字串相等1(Determining the String is Equal 1) 199
6.5.3 判斷字串相等2(Determining the String is Equal 2) 200
6.5.4 判斷字串相等3(Determining the String is Equal 3) 201
6.5.5 剩餘串排列1(Arranging Remaining String 1) 202
6.5.6 剩餘串排列2(Arranging Remaining String 2) 203
6.6 動態記憶體(Dynamic Memory) 204
6.6.1 預留向量空間(Reserving Vector Space) 204
6.6.2 蠻做素數判斷(Judging Prime Numbers Rudely) 205
6.6.3 空間換時間(Space for Time) 206
6.7 低級編程(Low-Level Programming) 208
6.7.1 C編程(C Programming) 208
6.7.2 低級篩法(Low-Grade Sieve) 209
6.7.3 篩法性能的比較(Comparison of Sieve Performance) 211
6.8 目的歸納(Conclusion) 213
練習6(Exercises 6) 214
第7章 程式結構(Program Structure) 219
7.1 函式組織(Function Organization) 220
7.1.1 程式構成(Program Composition) 220
7.1.2 程式檔案拆分(Program File Split) 221
7.2 頭檔案(Header File) 222
7.2.1 原始頭檔案(Original Header File) 222
7.2.2 界面頭檔案(Interface Header File) 224
7.2.3 頭檔案的內容(Content of Header File) 225
7.3 全局數據(Global Data) 226
7.3.1 全局數據訪問(Global Data Access) 226
7.3.2 消除全局數據(Eliminate Global Data) 228
7.3.3 一次定義原則(One-Definition Principle) 229
7.3.4 全局常量(Global Constant) 232
7.4 靜態數據(Static Data) 234
7.4.1 靜態全局數據(Static Global Data) 234
7.4.2 靜態局部數據(Static Local Data) 236
7.5 作用域與生命期(Scopes & Lifetime) 237
7.5.1 作用域(Scopes) 237
7.5.2 生命期(Lifetime) 239
7.6 名空間(Namespace) 241
7.6.1 名空間的概念(the Concept of Namespace) 241
7.6.2 名空間的組織(Namespace Organization) 242
7.6.3 組織模組(Module Organization) 244
7.6.4 數據名衝突(Data Name Conflict) 247
7.6.5 名空間的用法(Namespace Usage) 248
7.7 預編譯(Pre-Compilation) 249
7.7.1 #include指令(#include Directive) 250
7.7.2 條件編譯指令(Conditional Compiling Directive) 250
7.7.3 頭檔案衛士(Header Guard) 251
7.7.4 #define指令(#define Directive) 252
7.8 目的歸納(Conclusion) 253
練習7(Exercises 7) 253
第三部分 面向對象編程技術
Part Ⅲ The Object-Oriented Programming
第8章 類(Classes) 258
8.1 從結構到類(From Structure to Class) 259
8.1.1 定義結構(Defining Structure) 259
8.1.2 定義類(Defining Class) 261
8.2 成員函式(Member Functions) 263
8.2.1 成員函式定義(Member Function Definition) 263
8.2.2 使用對象指針(Using Object Pointer) 265
8.2.3 常成員函式(Constant Member Functions) 266
8.2.4 重載成員函式(Overloading Member Functions) 267
8.3 操作符(Operators) 268
8.3.1 函式重載特徵(Function Overloading Charcteristics) 268
8.3.2 性質(Characters) 270
8.3.3 值返回與引用返回(Returning Value or Reference) 271
8.3.4 增量操作符(Increment Operators) 272
8.3.5 成員操作符(Member Operators) 273
8.4 再論程式結構(Revisiting Program Structure) 275
8.4.1 訪問控制(Access Controls) 275
8.4.2 類的程式結構(Class Program Structure) 277
8.4.3 類作用域(Class Scope) 278
8.5 禁止類的實現(Shielding Implementation of Class) 280
8.5.1 意義(Significance) 280
8.5.2 影響編程方法(Influence Programming Method) 283
8.5.3 影響語言設計(Affecting Language Designing) 283
8.6 靜態成員(Static Members) 284
8.6.1 靜態數據成員(Static Data Members) 284
8.6.2 靜態成員函式(Static Member Functions) 286
8.7 友元(Friends) 287
8.7.1 頻繁調用問題(Frequent Call Problems) 287
8.7.2 提高訪問性能(Improving Access Performance) 290
8.7.3 其他特徵(Other Features) 293
8.8 目的歸納(Conclusion) 294
練習8(Exercises 8) 295
第9章 對象生滅(Object Birth & Death) 299
9.1 構造函式設計(Constructor Design) 300
9.1.1 初始化要求(Initialization Requirement) 300
9.1.2 封裝性要求(Encapsulation Requirement) 301
9.1.3 函式形式(Function Form) 301
9.1.4 無返回值(Non Return-Type) 302
9.1.5 set的缺憾(Shortcomings of set) 304

相關詞條

熱門詞條

聯絡我們