C++ Primer, 4/e (Paperback)
暫譯: C++ Primer, 第4版 (平裝本)

Stanley B. Lippman, Josée Lajoie, Barbara E. Moo

  • 出版商: Addison Wesley
  • 出版日期: 2005-02-24
  • 售價: $1,176
  • 語言: 英文
  • 頁數: 912
  • 裝訂: Paperback
  • ISBN: 0201721481
  • ISBN-13: 9780201721485
  • 相關分類: C++ 程式語言
  • 已過版

買這商品的人也買了...

相關主題

商品描述

Description

C++ Primer, Fourth Edition has been completely revised and rewritten to conform to today's C++ usage. Students new to C++ will find a clear and practically organized introduction to the language enhanced by numerous pedagogical aids. The fourth edition represents a complete restructuring and revision of the Primer. The authors’ motivation in this edition is to teach effective styles of modern C++ programming. To this end, they introduce the Standard Library and generic programming much earlier in the text. Many examples have been reformulated to take advantage of library facilities. Their focus is to show how to use the standard library abstractions rather than the low-level facilities built into the language.   They've also streamlined and reordered the presentation of language topics.  

Each chapter also contains a Summary section outlining the important topics covered in that chapter. Extensive forward and backward cross-references are provided to make it easier to follow the interrelationships among various features and concepts.   Occasional sidebar discussions are also provided to highlight important concepts, general advice or cautions. The authors have also incorporated a series of short sections that denote particularly important points, warn about common pitfalls, suggest good programming practices, and provide general usage tips.

 

Table of Contents

Preface     xix

Chapter 1. Getting Started      1
1.1 Writing a Simple C++ Program    2
1.2 A First Look at Input/Output     5
1.3 A Word About Comments     10
1.4 Control Structures     11
1.5 Introducing Classes    20
1.6 The C++ Program    25
Chapter Summary    28
Defined Terms    28


Part I. The Basics    31

Chapter 2. Variables and Basic Types    33
2.1 Primitive Built-in Types    34
2.2 Literal Constants     37
2.3 Variables     43
2.4 const Qualifier    56
2.5 References    58
2.6 Typedef Names    61
2.7 Enumerations    62
2.8 Class Types     63
2.9 Writing Our Own Header Files    67
Chapter Summary    73
Defined Terms     73

Chapter 3. Library Types      77
3.1 Namespace using Declarations      78
3.2 Library string Type     80
3.3 Library vector Type      90
3.4 Introducing Iterators      95
3.4.1 Iterator Arithmetic      100
3.5 Library bitset Type      101
Chapter Summary      107
Defined Terms      107

Chapter 4. Arrays and Pointers 109
4.1 Arrays      110
4.2 Introducing Pointers      114
4.3 C-Style Character Strings      130
4.4 Multidimensioned Arrays      141
Chapter Summary      145
Defined Terms      145

Chapter 5. Expressions      147
5.1 Arithmetic Operators      149
5.2 Relational and Logical Operators      152
5.3 The Bitwise Operators      154
5.4 Assignment Operators      159
5.5 Increment and Decrement Operators      162
5.6 The Arrow Operator      164
5.7 The Conditional Operator      165
5.8 The size of Operator      167
5.9 Comma Operator      168
5.10 Evaluating Compound Expressions      168
5.11 The new and delete Expressions      174
5.12 Type Conversions      178
Chapter Summary      188
Defined Terms      188

Chapter 6. Statements      191
6.1 Simple Statements      192
6.2 Declaration Statements      193
6.3 Compound Statements (Blocks)      193
6.4 Statement Scope      194
6.5 The if Statement      195
6.5.1 The if Statement else Branch      197
6.6 The switch Statement      199
6.7 The whileStatement      204
6.8 The for Loop Statement      207
6.9 The do while Statement      210
6.10 The break Statement      212
6.11 The continue Statement      214
6.12 The goto Statement      214
6.13 try Blocks and Exception Handling      215
6.13.1 A throw Expression      216
6.13.2 The try Block      217
6.13.3 Standard Exceptions      219
6.14 Using the Preprocessor for Debugging      220
Chapter Summary      223
Defined Terms      223

Chapter 7. Functions      225
7.1 Defining a Function      226
7.2 Argument Passing      229
7.3 The return Statement      245
7.4 Function Declarations      251
7.5 Local Objects      254
7.6 Inline Functions      256
7.7 ClassMemberFunctions      258
7.8 Overloaded Functions      265
7.9 Pointers to Functions      276
Chapter Summary      280
Defined Terms      280

Chapter 8. The IO Library      283
8.1 An Object-Oriented Library      284
8.2 Condition States      287
8.3 Managing the Output Buffer      290
8.4 File Input and Output      293
8.5 String Streams      299
Chapter Summary      302
Defined Terms      302


Part II. Containers and Algorithms      303

Chapter 9. Sequential Containers      305
9.1 Defining a Sequential Container      307
9.2 Iterators andIteratorRanges      311
9.3 Sequence Container Operations      316
9.4 How a vector Grows      330
9.5 Deciding Which Container to Use      333
9.6 strings Revisited      335
9.7 Container Adaptors      348
Chapter Summary      353
Defined Terms      353

Chapter 10. Associative Containers      355
10.1 Preliminaries: the pair Type      356
10.2 Associative Containers      358
10.3 The map Type      360
10.4 The set Type      372
10.5 The multimap and multiset Types      375
10.6 Using Containers: Text-Query Program      379
Chapter Summary      388
Defined Terms      388

Chapter 11. Generic Algorithms      391
11.1 Overview      392
11.2 A First Look at the Algorithms      395
11.3 Revisiting Iterators      405
11.4 Structure of Generic Algorithms      419
11.5 Container-Specific Algorithms      421
Chapter Summary      424
Defined Terms      424


Part III. Classes and Data Abstraction      427

Chapter 12. Classes      429
12.1 Class Definitions and Declarations         430
12.2 The Implicit this Pointer         440
12.3 Class Scope         444
12.4 Constructors         451
12.5 Friends         465
12.6 static Class Members         467
Chapter Summary         473
Defined Terms         473

Chapter 13 Copy Control      475
13.1 The Copy Constructor         476
13.2 The Assignment Operator         482
13.3 The Destructor           484
13.4 A Message-Handling Example       486
13.5 Managing Pointer Members         492
Chapter Summary         502
Defined Terms         502

Chapter 14. Overloaded Operations and Conversions      505
14.1 Defining an Overloaded Operator         506
14.2 Input andOutputOperators         513
14.3 Arithmetic and Relational Operators         517
14.4 Assignment Operators        520
14.5 Subscript Operator         522
14.6 Member Access Operators         523
14.7 Increment and Decrement Operators        526
14.8 Call Operator and Function Objects         530
14.9 Conversions and Class Types         535
Chapter Summary         . 552
Defined Terms         552


Part IV. Object-Oriented and Generic Programming      555

Chapter 15. Object-Oriented Programming      557
15.1 OOP: An Overview         558
15.2 Defining Base and Derived Classes         560
15.3 Conversions and Inheritance         577
15.4 Constructors and Copy Control         580
15.5 Class Scope under Inheritance         590
15.6 Pure Virtual Functions         595
15.7 Containers and Inheritance         597
15.8 Handle Classes and Inheritance         598
15.9 Text Queries Revisited         607
Chapter Summary         621
Defined Terms         621

Chapter 16. Templates and Generic Programming      623
16.1 Template Definitions         624
16.2 Instantiation           636
16.3 Template Compilation Models       643
16.4 Class Template Members         647
16.5 A Generic Handle Class         666
16.6 Template Specializations         671
16.7 Overloading and Function Templates         679
Chapter Summary        683
Defined Terms         683
Part V. Advanced Topics      685

Chapter 17. Tools for Large Programs      687
17.1 Exception Handling         688
17.2 Namespaces           712
17.3 Multiple and Virtual Inheritance       731
Chapter Summary         748
Defined Terms         748

Chapter 18. Specialized Tools and Techniques      753
18.1 Optimizing Memory Allocation         754
18.2 Run-Time Type Identification         772
18.3 Pointer to Class Member         780
18.4 Nested Classes         786
18.5 Union: A Space-Saving Class         792
18.6 Local Classes         796
18.7 Inherently Nonportable Features         797
Chapter Summary         805
Defined Terms         805

Appendix A. The Library      809
A.1 Library Names and Headers         810
A.2 A Brief Tour of the Algorithms         811
A.3 The IO Library Revisited         825
Index      843

商品描述(中文翻譯)

描述
《C++ Primer》第四版已完全修訂並重寫,以符合當今的 C++ 使用。對於新接觸 C++ 的學生來說,這本書提供了一個清晰且實用的語言介紹,並輔以眾多教學輔助工具。第四版代表了 Primer 的全面重組和修訂。作者在本版中的動機是教授現代 C++ 程式設計的有效風格。為此,他們在文本中更早地引入了標準庫和泛型程式設計。許多範例已重新編寫,以利用庫的功能。他們的重點是展示如何使用標準庫的抽象,而不是語言內建的低階功能。他們還簡化並重新排列了語言主題的呈現。

每一章還包含一個總結部分,概述該章所涵蓋的重要主題。提供了廣泛的前後交叉參考,以便更容易跟隨各種特徵和概念之間的相互關係。偶爾還會提供側邊討論,以突顯重要概念、一般建議或警告。作者還加入了一系列短小的部分,標示特別重要的要點,警告常見的陷阱,建議良好的程式設計實踐,並提供一般使用提示。

目錄
前言 xix
第一章. 開始使用 1
1.1 撰寫簡單的 C++ 程式 2
1.2 初步了解輸入/輸出 5
1.3 關於註解的說明 10
1.4 控制結構 11
1.5 介紹類別 20
1.6 C++ 程式 25
章節總結 28
定義術語 28

第一部分. 基礎 31
第二章. 變數和基本類型 33
2.1 原始內建類型 34
2.2 字面常數 37
2.3 變數 43
2.4 const 限定符 56
2.5 引用 58
2.6 typedef 名稱 61
2.7 列舉 62
2.8 類別類型 63
2.9 撰寫我們自己的標頭檔 67
章節總結 73
定義術語 73

第三章. 庫類型 77
3.1 命名空間使用聲明 78
3.2 庫字串類型 80
3.3 庫向量類型 90
3.4 介紹迭代器 95
3.4.1 迭代器運算 100
3.5 庫位元組類型 101
章節總結 107
定義術語 107

第四章. 陣列和指標 109
4.1 陣列 110
4.2 介紹指標 114
4.3 C 風格字元串 130
4.4 多維陣列 141
章節總結 145
定義術語 145

第五章. 表達式 147
5.1 算術運算子 149
5.2 關係和邏輯運算子 152
5.3 位元運算子 154
5.4 指派運算子 159
5.5 增量和減量運算子 162
5.6 箭頭運算子 164
5.7 條件運算子 165
5.8 size of 運算子 167
5.9 逗號運算子 168
5.10 評估複合表達式 168
5.11 new 和 delete 表達式 174
5.12 類型轉換 178
章節總結 188
定義術語 188

第六章. 語句 191
6.1 簡單語句 192
6.2 聲明語句 193
6.3 複合語句(區塊) 193
6.4 語句範圍 194
6.5 if 語句 195
6.5.1 if 語句的 else 分支 197
6.6 switch 語句 199
6.7 while 語句 204
6.8 for 迴圈語句 207
6.9 do while 語句 210
6.10 break 語句 212
6.11 continue 語句 214
6.12 goto 語句 214
6.13 try 區塊和例外處理 215
6.13.1 throw 表達式 216
6.13.2 try 區塊 217
6.13.3 標準例外 219
6.14 使用預處理器進行除錯 220
章節總結 223
定義術語 223

第七章. 函數 225
7.1 定義函數 226
7.2 參數傳遞 229
7.3 return 語句 245
7.4 函數聲明 251
7.5 本地物件 254
7.6 內聯函數 256
7.7 類別成員函數 258
7.8 重載函數 265
7.9 指向函數的指標 276
章節總結 280
定義術語 280

第八章. IO 庫 283
8.1 物件導向庫 284
8.2 條件狀態 287
8.3 管理輸出緩衝區 290
8.4 檔案輸入和輸出 293
8.5 字串流 299
章節總結 302
定義術語 302

第二部分. 容器和演算法 303
第九章. 順序容器 305
9.1 定義順序容器 307
9.2 迭代器和迭代範圍 311
9.3 順序容器操作 316
9.4 向量的增長 330
9.5 決定使用哪個容器 333
9.6 字串重訪 335
9.7 容器適配器 348
章節總結 353
定義術語 353

第十章. 關聯容器 355
10.1 初步:pair 類型 356
10.2 關聯容器 358
10.3 map 類型 360
10.4 set 類型 372
10.5 multimap 和 multiset 類型 375
10.6 使用容器:文本查詢程式 379
章節總結 388
定義術語 388

第十一章. 泛型演算法 391
11.1 概述 392
11.2 初步了解演算法 395
11.3 重新訪問迭代器 405
11.4 泛型演算法的結構 419
11.5 容器特定演算法 421
章節總結 424
定義術語 424

第三部分. 類別和資料抽象 427
第十二章. 類別 429
12.1 類別定義和聲明 430
12.2 隱含的 this 指標 440
12.3 類別範圍 444
12.4 建構函數 451
12.5 友元 465
12.6 靜態類別成員 467
章節總結 473
定義術語 473

第十三章. 複製控制 475
13.1 複製建構函數 476
13.2 指派運算子 482
13.3 解構函數 484
13.4 一個訊息處理範例 486
13.5 管理指標成員 492
章節總結 502
定義術語 502