C++ Programmer's Notebook, 2/e
暫譯: C++ 程式設計師筆記本,第二版

Jim Keogh, James Edward Keogh, John Shapley Gray

  • 出版商: Prentice Hall
  • 出版日期: 2001-08-16
  • 售價: $1,350
  • 貴賓價: 9.5$1,283
  • 語言: 英文
  • 頁數: 508
  • 裝訂: Paperback
  • ISBN: 0130887013
  • ISBN-13: 9780130887016
  • 相關分類: C++ 程式語言
  • 海外代購書籍(需單獨結帳)

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

相關主題

商品描述

  • Learn C++ fast! Real code, thoroughly explained-and ready to use!
  • Completely updated with over 200 new examples
  • All the fundamentals: variables, operators, arrays, functions, program control, I/O, files, streams, memory management, sorts, searches, and more
  • Advanced topics: data structures, templates, string classes, and exception handling
  • See the code and put it to work—fast, easy, and hands on

C++ Programmer's Notebook, Second Edition teaches C++ the way you want to learn it: with real code! This quick, visual tutorial presents hundreds of annotated "snapshots" of working code, covering all the C++ concepts and techniques you need—and delivering specific solutions you can use right now!

Practical, comprehensive coverage includes:

  • Variables, operators, expressions, arrays, and C-style strings
  • Structures, functions, and program control
  • Objects, classes, overloading, inheritance, and pointers
  • Virtual and friend functions
  • I/O, files, streams, and memory management
  • Sorts and searches
  • Data structures and templates
  • String classes and exception handling
  • Quality checklists for building robust, high-performance code!

Completely updated with over 200 new examples, C++ Programmer's Notebook, Second Edition is the perfect starting point for new C++ developers-and the perfect reference for experienced C++ developers looking for quick solutions!

Table of Contents

Preface.
1. Working with Variables.

Naming Variables. Using Variables. Boolean Variables. Integer Variables. Character Variables. Escape Sequences. Floating Point Variables. Inside Exponential Notation. Data Type Conversion. Assigning Values to Variables. Constants. Scope. Local Variables versus Global Variables. File and Class Scope. Storage Specifiers. Static. Register. Auto. Storage Specifier Rules.


2. Working with Operators and Expressions.

Expressions. Arithmetic Operators. The +=, -=, *=, /= Operators. The ++, -- Operators. Relational Operators. The == and != Operators. Logical Operators. Bitwise Operators. Bitwise AND. Bitwise OR. Bitwise XOR (exclusive OR). Bitwise NOT. The Shift Left Operator. The Shift Right Operator. ?-The Conditional Operator. An Introduction to Indirection. The Precedence Table. Working with Expressions.


3. Working with Arrays and C-Style Strings.

Arrays and Strings. Assigning Values to an Array. Multidimensional Arrays. Assigning Values to a Multidimensional Array. Allocating Arrays Using the new Operator. Allocating Multidimensional Arrays Using the new Operator. C-Style Strings. Copying One C-Style String to Another Using strcpy( ) and strncpy( ). Reading in a C-Style String Using gets( )and fgets( ). Reading a C-Style String from the Keyboard Using scanf( ). Reading a C-Style String from the Keyboard with the Extraction Operator. Reading a C-Style String from the Keyboard with get( ) and getline( ). Comparing Two C-Style Strings. Displaying a C-Style String with printf( ). Displaying a C-Style String with puts( ). Displaying a String with the Insertion Operator. Concatenating C-Style Strings with strcat( ) and strncat( ). Determining the Length of a C-Style String with strlen( ). Determining the Length of a Substring with strcspn( ). Determining the Length of a Substring with strspn( ). Locating a Character within a C-Style String Using strpbrk( ). Locating the First Occurrence of a Substring in a C-Style String with strstr( ). Dividing a C-Style String into Several Substrings Using strtok( ). C-Style Strings versus the String Types of the C++ Standard Library.


4. Working with Structures.

Structures. A Structure at Work. Running the Sample Program. Other Ways to Declare an Instance of a Structure. Assigning Values to Structure Members. Multiple Instances of Structures. Assigning Values to Multiple Instances. Structures within Structures. Passing Members of a Structure to a Function. Passing Members by Address. Passing a Structure to a Function. Passing a Structure to a Function by Reference. Functions Returning Structures. Unions. Enumerations. The typedef Declaration.


5. Working with Functions.

Anatomy of a C++ Program. The main( ) Function. How to Use a Function. Passing Arguments by Value. Passing Multiple Arguments. Passing Arguments Using Reference Variables. Passing Arguments to the main( ) Function. Returning Values. Building a Program Using Functions. Additional Function Facts. Program Statements. White Space Characters. Preprocessor Directives. More Preprocessor Directives. #define with Arguments. inline Function. #if, #else, #elif, #endif. #ifdef, #ifndef, #undef. Using Include Once Header Files. #line, #error, and #pragma.


6. Working with Program Control.

Program Control Statements. The if Statement. The if...else Statement. The ? Operator. Nested if. Multiple Conditions. The switch...case Statement. Tricks of the Trade. for Loop. More on for Loops. while Loop. do...while Loop. break. Continue. exit( ). goto.


7. Working with Objects and Classes.

Classes. Declaring an Instance of a Class. Hiding Data Using the Access Control Specifier. The Constructor. More on Initialization. The Destructor. The Copy Constructor. Defining a Function Member outside the Class Declaration.


8. Working with Overloading.

Overloading. Overloading a Unary Operator. Overloading a Binary Operator. Overloading the Input and Output Operators. Operators that Can and Cannot Be Overloaded.


9. Working with Inheritance.

Inheritance. Access Specifiers. More about Inheritance. Multiple Inheritance. Ambiguity in Multiple Inheritance. Containership Class. Levels of Inheritance.


10. Working with Pointers.

Pointers and References. More on Using Pointers. Incrementing Pointers. Decrementing Pointers. Pointer Math. An Array of Pointers. Pointer-to-a-Pointer. Pointer-to-a-Function. Tricks of the Trade.


11. Working with Virtual and Friend Functions.

Creating a Virtual Function. Virtual Destructors. Creating a Pure Virtual Function. More about Virtual Functions. Friend Functions. Creating a Friend Function from a Function Member Forward Reference of a Class. Friend Classes.


12. Working with Keyboard Input and Screen Output.

C-Style Keyboard Input and Screen Output. Reading a Character from the Keyboard without Echo Using getch( )and _getch( ). Displaying a Character on the Screen with putchar( ). Reading a String from the Keyboard with Less Overhead Using gets( ). Reading Input with Greater Control Using scanf( ). Reading Data with scanf( ). Limiting the Number of Characters Read. Specifying Input String Contents. Creating Your Own Separator. Displaying a String with Less Overhead Using puts( ). Displaying a String with Greater Control Using printf( ). Displaying a String with printf( ). Displaying an Integer with printf( ).


13. Working with Files and Streams.

File Input/Output and Opening and Closing a File. Mode Specifiers for the fopen( ) Function. Writing a Character to a File Using putc( )and fputc( ). Reading a Character from a File Using getc( ). Tricks of the Trade. Writing a String to a File Using fputs( ). Reading a String from a File Using fgets( ). Writing an Integer to a File Using putw( ). Reading an Integer from a File Using getw( ). Writing a Block of Data to a File Using fwrite( ). Reading a Block of Data from a File Using fread( ). Creating a Database File. Reading a Record. Writing Various Data Types to a File or a String Using fprintf( ) and sprintf( ). Reading Various Data Types from a File or a String Using fscanf( ) and sscanf( ). Moving to Specific Locations in a File Using fseek( ). Other File Manipulation Functions. Using a File in C++. Writing Information to a File Using C++. Reading a String from a File Using C++. Reading and Writing a Single Character to a File Using C++. Reading and Writing an Object to a File. Specify the File Mode in C++. Moving to Specific Locations in an Input Using File Using seekg( )and tellg( ). Moving to Specific Locations in an Output File Using seekp( ) and tellp( ). Reading and Writing to the Same File.


14. Working with Memory Management.

Computer Memory. Data in the Program Process Space. Storing Data on the Heap. Storing an Array of Objects on the Heap. Reallocating Heap Memory. Storing Data on the Heap Using the new Operator. Using a Dynamic Array. More on Dynamic Arrays.


15. Working with Sorting and Searching Data.

The Bubble Sort. Inside the Bubble Sort. The Selection Sort. Inside the Selection Sort. The Quick Sort. Inside the Quick Sort. The Sequential (Linear) Search. The Binary Search. A Closer Look at the Binary Search Routine. Using bsearch( ).


16. Working with Data Structures.

Linked Lists. Adding a Node to the End of a Linked List. Adding a Node to Maintain Sorted Order. Removing a Node from a Linked List. Linked List Operators. More on Linked List Operators. Stacks. Implementing a Stack as an Array. Implementing a Stack as a Linked List. Using a Linked List Stack. Queues. Implementing a Queue as an Array. Implementing a Queue as a Linked List. Using a Linked List Queue.


17. Working with Templates.

Templates. Using Template Functions with a Defined Type. Templates with Multiple Parameters. Class Templates. Template Class Friendships.


18. Working with Assertions and Exceptions.

Assertions. try, catch, and throw. More about try, catch, and throw. Functions that Throw Exceptions. Throwing Objects.


Appendix A: A User-Defined String Class.
Appendix B: Keeping Current.
Appendix C: Programmer's Checklist.
Appendix D: ASCII Codes.
Index.

商品描述(中文翻譯)

- 快速學習 C++!真實的程式碼,詳細解釋並隨時可用!
- 完全更新,新增超過 200 個範例
- 所有基本概念:變數、運算子、陣列、函數、程式控制、I/O、檔案、串流、記憶體管理、排序、搜尋等等
- 進階主題:資料結構、模板、字串類別和例外處理
- 查看程式碼並快速實作—簡單、快速且實用

《C++ 程式設計師筆記(第二版)》以您想要的方式教您 C++:使用真實的程式碼!這本快速、視覺化的教程提供數百個註解的「快照」工作程式碼,涵蓋您所需的所有 C++ 概念和技術,並提供您現在可以使用的具體解決方案!

實用且全面的內容包括:
- 變數、運算子、表達式、陣列和 C 風格字串
- 結構、函數和程式控制
- 物件、類別、重載、繼承和指標
- 虛擬函數和友元函數
- I/O、檔案、串流和記憶體管理
- 排序和搜尋
- 資料結構和模板
- 字串類別和例外處理
- 建立穩健、高效能程式碼的品質檢查清單!

《C++ 程式設計師筆記(第二版)》完全更新,新增超過 200 個範例,是新手 C++ 開發者的完美起點,也是尋求快速解決方案的資深 C++ 開發者的完美參考!

**目錄**
前言。
1. 使用變數。
命名變數。使用變數。布林變數。整數變數。字元變數。轉義序列。浮點變數。指數表示法。資料型別轉換。給變數賦值。常數。範圍。區域變數與全域變數。檔案和類別範圍。儲存規範。靜態。寄存器。自動。儲存規範規則。

2. 使用運算子和表達式。
表達式。算術運算子。+=、-=、*=、/= 運算子。++、-- 運算子。關係運算子。== 和 != 運算子。邏輯運算子。位元運算子。位元 AND。位元 OR。位元 XOR(異或)。位元 NOT。左移運算子。右移運算子。條件運算子。間接引用介紹。優先順序表。使用表達式。

3. 使用陣列和 C 風格字串。
陣列和字串。給陣列賦值。多維陣列。給多維陣列賦值。使用 new 運算子配置陣列。使用 new 運算子配置多維陣列。C 風格字串。使用 strcpy() 和 strncpy() 複製一個 C 風格字串到另一個。使用 gets() 和 fgets() 讀取 C 風格字串。使用 scanf() 從鍵盤讀取 C 風格字串。使用提取運算子從鍵盤讀取 C 風格字串。使用 get() 和 getline() 從鍵盤讀取 C 風格字串。比較兩個 C 風格字串。使用 printf() 顯示 C 風格字串。使用 puts() 顯示 C 風格字串。使用插入運算子顯示字串。使用 strcat() 和 strncat() 串接 C 風格字串。使用 strlen() 確定 C 風格字串的長度。使用 strcspn() 確定子字串的長度。使用 strspn() 確定子字串的長度。使用 strpbrk() 在 C 風格字串中定位字元。使用 strstr() 在 C 風格字串中定位子字串的第一次出現。使用 strtok() 將 C 風格字串分割成幾個子字串。C 風格字串與 C++ 標準庫的字串類型。

4. 使用結構。
結構。結構的工作。運行範例程式。宣告結構實例的其他方法。給結構成員賦值。結構的多個實例。給多個實例賦值。結構中的結構。將結構的成員傳遞給函數。按地址傳遞成員。將結構傳遞給函數。按引用將結構傳遞給函數。返回結構的函數。聯合。列舉。typedef 聲明。

5. 使用函數。
C++ 程式的結構。main() 函數。如何使用函數。按值傳遞參數。傳遞多個參數。使用引用變數傳遞參數。將參數傳遞給 main() 函數。返回值。使用函數構建程式。其他函數事實。程式語句。空白字元。預處理指令。更多預處理指令。帶參數的 #define。inline 函數。#if、#else、#elif、#endif。#ifdef、#ifndef、#undef。使用 Include Once 標頭檔。#line、#error 和 #pragma。

6. 使用程式控制。
程式控制語句。if 語句。if...else 語句。? 運算子。巢狀 if。多個條件。switch...case 語句。行業技巧。for 迴圈。更多關於 for 迴圈的內容。while 迴圈。do...while 迴圈。break。continue。exit()。goto。

7. 使用物件和類別。
類別。宣告類別的實例。使用存取控制規範隱藏資料。建構函數。更多關於初始化的內容。解構函數。複製建構函數。在類別宣告外定義函數成員。

8. 使用重載。
重載。重載一元運算子。重載二元運算子。重載輸入和輸出運算子。可以和不可以重載的運算子。

9. 使用繼承。
繼承。存取規範。更多關於繼承的內容。多重繼承。在多重繼承中的歧義。包含類別。繼承的層級。

10. 使用指標。
指標和引用。更多關於使用指標的內容。遞增指標。遞減指標。指標運算。指標陣列。指向指標的指標。指向函數的指標。行業技巧。

11. 使用虛擬和友元函數。
創建虛擬函數。虛擬解構函數。創建純虛擬函數。更多關於虛擬函數的內容。友元函數。從函數成員前向引用創建友元函數。友元類別。

12. 使用鍵盤輸入和螢幕輸出。
C 風格的鍵盤輸入和螢幕輸出。使用 getch() 和 _getch() 從鍵盤讀取字元而不回顯。使用 putchar() 在螢幕上顯示字元。使用 gets() 以較少的開銷從鍵盤讀取字串。使用 scanf() 以更大的控制讀取輸入。使用 scanf() 讀取資料。限制讀取的字元數。指定輸入字串內容。創建自己的分隔符。使用 puts() 以較少的開銷顯示字串。使用 printf() 以更大的控制顯示字串。使用 printf() 顯示字串。使用 printf() 顯示整數。

13. 使用檔案和串流。
檔案輸入/輸出及開啟和關閉檔案。fopen() 函數的模式規範。使用 putc() 和 fputc() 將字元寫入檔案。使用 getc() 從檔案讀取字元。行業技巧。使用 fputs() 將字串寫入檔案。使用 fgets() 從檔案讀取字串。使用 putw() 將整數寫入檔案。使用 getw() 從檔案讀取整數。使用 fwrite() 將資料區塊寫入檔案。使用 fread() 從檔案讀取資料區塊。創建資料庫檔案。讀取記錄。使用 fprintf() 和 sprintf() 將各種資料型別寫入檔案或字串。使用 fscanf() 和 sscanf() 從檔案或字串讀取各種資料型別。使用 fseek() 移動到檔案中的特定位置。其他檔案操作函數。在 C++ 中使用檔案。使用 C++ 將資訊寫入檔案。使用 C++ 從檔案讀取字串。使用 C++ 讀寫單一字元到檔案。使用 C++ 讀寫物件到檔案。在 C++ 中指定檔案模式。使用 seekg() 和 tellg() 移動到輸入檔案中的特定位置。使用 seekp() 和 tellp() 移動到輸出檔案中的特定位置。讀寫同一檔案。

14. 使用記憶體管理。
電腦記憶體。程式處理空間中的資料。在堆上儲存資料。在堆上儲存物件陣列。重新配置堆記憶體。使用 new 運算子在堆上儲存資料。使用動態陣列。更多關於動態陣列的內容。

15. 使用排序和搜尋資料。
氣泡排序。氣泡排序的內部運作。選擇排序。選擇排序的內部運作。快速排序。快速排序的內部運作。順序(線性)搜尋。二元搜尋。更深入了解二元搜尋例程。使用 bsearch()。

16. 使用資料結構。
鏈結串列。將節點添加到鏈結串列的末尾。添加節點以維持排序。從鏈結串列中移除節點。鏈結串列運算子。更多關於鏈結串列運算子的內容。堆疊。將堆疊實作為陣列。將堆疊實作為鏈結串列。使用鏈結串列堆疊。佇列。將佇列實作為陣列。將佇列實作為鏈結串列。使用鏈結串列佇列。

17. 使用模板。
模板。使用定義型別的模板函數。具有多個參數的模板。類別模板。模板類別友誼。

18. 使用斷言和例外。
斷言。try、catch 和 throw。更多關於 try、catch 和 throw 的內容。拋出例外的函數。拋出物件。

附錄 A:使用者定義字串類別。附錄 B:保持最新。附錄 C:程式設計師檢查清單。附錄 D:ASCII 碼。索引。