滿漢全席之外(譯序/侯捷) ........................................................................................ v
前言Preface ................................................................................................................... xi
結構與組織 ............................................................................................................... xiii
關於源代碼 ............................................................................................................... xiii
緻謝 .......................................................................................................................... xiv
更多讀物 ................................................................................................................... xiv
排版約定 .................................................................................................................... xv
第1 章 C++編程基礎 Basic C++ Programming ........................................................... 1
1.1 如何撰寫C++程序 ............................................................................................ 1
1.2 對象的定義與初始化 ......................................................................................... 7
1.3 撰寫錶達式 ....................................................................................................... 10
1.4 條件語句和循環語句 ....................................................................................... 15
1.5 如何運用Array 和Vector ................................................................................ 22
1.6 指針帶來彈性 ................................................................................................... 26
1.7 文件的讀寫 ....................................................................................................... 30
第2 章 麵嚮過程的編程風格 Procedural Programming ........................................ 35
2.1 如何編寫函數 ................................................................................................... 35
2.2 調用函數 ........................................................................................................... 41
2.3 提供默認參數值 ............................................................................................... 50
2.4 使用局部靜態對象 ........................................................................................... 53
2.5 聲明inline 函數 ................................................................................................ 55
2.6 提供重載函數 ................................................................................................... 56
2.7 定義並使用模闆函數 ....................................................................................... 58
2.8 函數指針帶來更大的彈性 ............................................................................... 60
2.9 設定頭文件 ....................................................................................................... 63
第3 章 泛型編程風格 Generic Programming ........................................................ 67
3.1 指針的算術運算 ............................................................................................... 68
3.2 瞭解Iterator(泛型指針) .............................................................................. 73
3.3 所有容器的共通操作 ....................................................................................... 76
3.4 使用順序性容器 ............................................................................................... 77
3.5 使用泛型算法 ................................................................................................... 81
3.6 如何設計一個泛型算法 ................................................................................... 83
3.7 使用Map .......................................................................................................... 90
3.8 使用Set ............................................................................................................. 91
3.9 如何使用Iterator Inserter ................................................................................. 93
3.10 使用iostream Iterator ....................................................................................... 95
第4 章 基於對象的編程風格 Object-Based Programming ...................................... 99
4.1 如何實現一個Class ....................................................................................... 100
4.2 什麼是構造函數和析構函數 ......................................................................... 104
4.3 何謂mutable(可變)和const(不變) .................................................. 109
4.4 什麼是this 指針 ........................................................................................... 113
4.5 靜態類成員 ..................................................................................................... 115
4.6 打造一個Iterator Class .................................................................................. 118
4.7 閤作關係必須建立在友誼的基礎上 ............................................................. 123
4.8 實現一個copy assignment operator ............................................................... 125
4.9 實現一個function object ................................................................................ 126
4.10 重載iostream 運算符 ..................................................................................... 128
4.11 指針,指嚮Class Member Function .............................................................. 130
第5 章 麵嚮對象編程風格 Object-Oriented Programming ..................................... 135
5.1 麵嚮對象編程概念 ......................................................................................... 135
5.2 漫遊:麵嚮對象編程思維 ............................................................................. 138
5.3 不帶繼承的多態 ............................................................................................. 142
5.4 定義一個抽象基類 ......................................................................................... 145
5.5 定義一個派生類 ............................................................................................. 148
5.6 運用繼承體係 ................................................................................................. 155
5.7 基類應該多麼抽象 ......................................................................................... 157
5.8 初始化、析構、復製 ..................................................................................... 158
5.9 在派生類中定義一個虛函數 ......................................................................... 160
5.10 運行時的類型鑒定機製 ................................................................................. 164
第6 章 以template 進行編程 Programming with Templates .................................... 167
6.1 被參數化的類型 ............................................................................................. 169
6.2 Class Template 的定義 ................................................................................... 171
6.3 Template 類型參數的處理 ............................................................................. 172
6.4 實現一個Class Template ............................................................................... 174
6.5 一個以Function Template 完成的Output 運算符 ........................................ 180
6.6 常量錶達式與默認參數值 ............................................................................. 181
6.7 以Template 參數作為一種設計策略 ............................................................ 185
6.8 Member Template Function ............................................................................ 187
第7 章 異常處理 Exception Handling .................................................................. 191
7.1 拋齣異常 ......................................................................................................... 191
7.2 捕獲異常 ......................................................................................................... 193
7.3 提煉異常 ......................................................................................................... 194
7.4 局部資源管理 ................................................................................................. 198
7.5 標準異常 ......................................................................................................... 200
附錄A 習題解答 Exercises Solutions ............................................................................ 205
附錄B 泛型算法參考手冊 Generic Algorithms Handbook .................................. 255
附錄C 中英術語對照 侯捷 ..................................................................................... 271
英文術語的采用原則 .............................................................................................. 271
中英術語對照(按字母順序排列) ...................................................................... 272
索引 Index ................................................................................................................. 277
· · · · · · (
收起)