You are previewing C++ How to Program, Sixth Edition.
O'Reilly logo
C++ How to Program, Sixth Edition

Book Description

For Introduction to Programming (CS1) and other more intermediate courses covering programming in C++. Also appropriate as a supplement for upper-level courses where the instructor uses a book as a reference for the C++ language.

This best-selling comprehensive text is aimed at readers with little or no programming experience. It teaches programming by presenting the concepts in the context of full working programs and takes and early objects approach. The text has an emphasis on achieving program clarity through structured and object-oriented programming, software reuse and component-oriented software construction. The Sixth Edition reflects the suggested improvements of a distinguished team of industry professionals and academics.

Table of Contents

  1. Copyright
    1. Dedication
  2. Deitel® Series Page
    1. How To Program Series
    2. Simply Series
    3. SafariX Web Books
  3. Deitel Resource Centers
  4. Preface
    1. New and Updated Features
    2. Teaching Approach
    3. Tour of the Book
    4. Object-Oriented Design of an ATM with the UML: A Tour of the Optional Software Engineering Case Study
      1. Student Resources Included with C++ How to Program, 6/e
        1. Warnings and Error Messages on Older C++ Compilers
        2. Notes Regarding using Declarations and C Standard Library Functions
      2. C++ Multimedia Cyber Classroom, 6/e
      3. Instructor Resources for C++ How to Program, 6/e
      4. Deitel® Buzz Online Free E-mail Newsletter
      5. The Deitel Online Resource Centers
  5. Acknowledgments
    1. C++ How to Program 6/e Reviewers
    2. C++ How to Program 5/e Reviewers
  6. About the Authors
    1. About Deitel & Associates, Inc.
  7. Before You Begin
    1. Downloading the C++ How to Program, 6/e Example Code
    2. Installing/Choosing a Compiler
  8. 1. Introduction to Computers, the Internet and the World Wide Web
    1. 1.1. Introduction
    2. 1.2. What Is a Computer?
    3. 1.3. Computer Organization
    4. 1.4. Early Operating Systems
    5. 1.5. Personal, Distributed and Client/Server Computing
    6. 1.6. The Internet and the World Wide Web
    7. 1.7. Web 2.0
    8. 1.8. Machine Languages, Assembly Languages and High-Level Languages
    9. 1.9. History of C and C++
    10. 1.10. C++ Standard Library
    11. 1.11. History of Java
    12. 1.12. Fortran, COBOL, Pascal and Ada
    13. 1.13. BASIC, Visual Basic, Visual C++, C# and .NET
    14. 1.14. Key Software Trend: Object Technology
    15. 1.15. Typical C++ Development Environment
      1. Phase 1: Creating a Program
      2. Phases 2 and 3: Preprocessing and Compiling a C++ Program
      3. Phase 4: Linking
      4. Phase 5: Loading
      5. Phase 6: Execution
      6. Problems That May Occur at Execution Time
    16. 1.16. Notes About C++ and C++ How to Program, 6/e
    17. 1.17. Test-Driving a C++ Application
      1. Running a C++ Application from the Windows XP Command Prompt
      2. Running a C++ Application Using GNU C++ with Linux
    18. 1.18. Software Technologies
    19. 1.19. Game Programming with the Ogre Libraries
    20. 1.20. Future of C++: Open Source Boost Libraries, TR1 and C++0x
    21. 1.21. Software Engineering Case Study: Introduction to Object Technology and the UML
      1. Basic Object Technology Concepts
      2. Classes, Data Members and Member Functions
      3. Introduction to Object-Oriented Analysis and Design (OOAD)
      4. History of the UML
      5. What Is the UML?
      6. UML Web Resources
      7. Recommended Readings
      8. Section 1.21 Self-Review Exercises
      9. Answers to Section 1.21 Self-Review Exercises
    22. 1.22. Wrap-Up
    23. 1.23. Web Resources
      1. Deitel & Associates Web Sites
      2. Compilers and Development Tools
      3. Resources
      4. Games and Game Programming
    24. Summary
      1. Section 1.1 Introduction
      2. Section 1.2 What Is a Computer?
      3. Section 1.3 Computer Organization
      4. Section 1.4 Early Operating Systems
      5. Section 1.5 Personal, Distributed and Client/Server Computing
      6. Section 1.6 The Internet and the World Wide Web
      7. Section 1.7 Web 2.0
      8. Section 1.8 Machine Languages, Assembly Languages and High-Level Languages
      9. Section 1.9 History of C and C++
      10. Section 1.10 C++ Standard Library
      11. Section 1.11 History of Java
      12. Section 1.12 Fortran, COBOL, Pascal and Ada
      13. Section 1.13 BASIC, Visual Basic, Visual C++, C# and .NET
      14. Section 1.14 Key Software Trend: Object Technology
      15. Section 1.15 Typical C++ Development Environment
      16. Section 1.18 Software Technologies
      17. Section 1.19 Game Programming with the Ogre Libraries
      18. Section 1.20 Future of C++: Open Source Boost Libraries, TR1 and C++0x
      19. Section 1.21 Software Engineering Case Study: Introduction to Object Technology and the UML
    25. Terminology
    26. Self-Review Exercises
    27. Answers to Self-Review Exercises
    28. Exercises
  9. 2. Introduction to C++ Programming
    1. 2.1. Introduction
    2. 2.2. First Program in C++: Printing a Line of Text
    3. 2.3. Modifying Our First C++ Program
      1. Printing a Single Line of Text with Multiple Statements
      2. Printing Multiple Lines of Text with a Single Statement
    4. 2.4. Another C++ Program: Adding Integers
    5. 2.5. Memory Concepts
    6. 2.6. Arithmetic
      1. Arithmetic Expressions in Straight-Line Form
      2. Parentheses for Grouping Subexpressions
      3. Rules of Operator Precedence
      4. Sample Algebraic and C++ Expressions
      5. Evaluation of a Second-Degree Polynomial
    7. 2.7. Decision Making: Equality and Relational Operators
    8. 2.8. (Optional) Software Engineering Case Study: Examining the ATM Requirements Specification
      1. Requirements Specification
      2. Analyzing the ATM System
      3. Use Case Diagrams
      4. Designing the ATM System
      5. Internet and Web Resources
      6. Recommended Readings
      7. Software Engineering Case Study Self-Review Exercises
      8. Answers to Software Engineering Case Study Self-Review Exercises
    9. 2.9. Wrap-Up
    10. Summary
      1. Section 2.2 First Program in C++: Printing a Line of Text
      2. Section 2.4 Another C++ Program: Adding Integers
      3. Section 2.5 Memory Concepts
      4. Section 2.6 Arithmetic
      5. Section 2.7 Decision Making: Equality and Relational Operators
    11. Terminology
    12. Self-Review Exercises
    13. Answers to Self-Review Exercises
    14. Exercises
  10. 3. Introduction to Classes and Objects
    1. 3.1. Introduction
    2. 3.2. Classes, Objects, Member Functions and Data Members
    3. 3.3. Overview of the Chapter Examples
    4. 3.4. Defining a Class with a Member Function
      1. Class GradeBook
      2. Testing Class GradeBook
      3. UML Class Diagram for Class GradeBook
    5. 3.5. Defining a Member Function with a Parameter
      1. Defining and Testing Class GradeBook
      2. More on Arguments and Parameters
      3. Updated UML Class Diagram for Class GradeBook
    6. 3.6. Data Members, set Functions and get Functions
      1. GradeBook Class with a Data Member, a set Function and a get Function
      2. Access Specifiers public and private
      3. Member Functions setCourseName and getCourseName
      4. Member Function displayMessage
      5. Testing Class GradeBook
      6. Software Engineering with Set and Get Functions
      7. GradeBook’s UML Class Diagram with a Data Member and set and get Functions
    7. 3.7. Initializing Objects with Constructors
      1. Defining a Constructor
      2. Testing Class GradeBook
      3. Two Ways to Provide a Default Constructor for a Class
      4. Adding the Constructor to Class GradeBook’s UML Class Diagram
    8. 3.8. Placing a Class in a Separate File for Reusability
      1. Header Files
      2. Including a Header File That Contains a User-Defined Class
      3. How Header Files Are Located
      4. Additional Software Engineering Issues
    9. 3.9. Separating Interface from Implementation
      1. Interface of a Class
      2. Separating the Interface from the Implementation
      3. GradeBook.h: Defining a Class’s Interface with Function Prototypes
      4. GradeBook.cpp: Defining Member Functions in a Separate Source-Code File
      5. Testing Class GradeBook
      6. The Compilation and Linking Process
    10. 3.10. Validating Data with set Functions
      1. GradeBook Class Definition
      2. Validating the Course Name with GradeBook Member Function setCourseName
      3. Testing Class GradeBook
      4. Additional Notes on Set Functions
    11. 3.11. (Optional) Software Engineering Case Study: Identifying the Classes in the ATM Requirements Specification
      1. Identifying the Classes in a System
      2. Modeling Classes
      3. Software Engineering Case Study Self-Review Exercises
      4. Answers to Software Engineering Case Study Self-Review Exercises
    12. 3.12. Wrap-Up
    13. Summary
      1. Section 3.2 Classes, Objects, Member Functions and Data Members
      2. Section 3.4 Defining a Class with a Member Function
      3. Section 3.5 Defining a Member Function with a Parameter
      4. Section 3.6 Data Members, set Functions and get Functions
      5. Section 3.7 Initializing Objects with Constructors
      6. Section 3.8 Placing a Class in a Separate File for Reusability
      7. Section 3.9 Separating Interface from Implementation
      8. Section 3.10 Validating Data with set Functions
    14. Terminology
    15. Self-Review Exercises
    16. Answers to Self-Review Exercises
    17. Exercises
  11. 4. Control Statements: Part 1
    1. 4.1. Introduction
    2. 4.2. Algorithms
    3. 4.3. Pseudocode
    4. 4.4. Control Structures
      1. Sequence Structure in C++
      2. Selection Statements in C++
      3. Repetition Statements in C++
      4. Summary of Control Statements in C++
    5. 4.5. if Selection Statement
    6. 4.6. if...else Double-Selection Statement
      1. Conditional Operator (?:)
      2. Nested if...else Statements
      3. Dangling-else Problem
      4. Blocks
    7. 4.7. while Repetition Statement
    8. 4.8. Formulating Algorithms: Counter-Controlled Repetition
      1. Pseudocode Algorithm with Counter-Controlled Repetition
      2. Enhancing GradeBook Validation
      3. Implementing Counter-Controlled Repetition in Class GradeBook
      4. Demonstrating Class GradeBook
      5. Notes on Integer Division and Truncation
    9. 4.9. Formulating Algorithms: Sentinel-Controlled Repetition
      1. Developing the Pseudocode Algorithm with Top-Down, Stepwise Refinement: The Top and First Refinement
      2. Proceeding to the Second Refinement
      3. Implementing Sentinel-Controlled Repetition in Class GradeBook
      4. Program Logic for Sentinel-Controlled Repetition vs. Counter-Controlled Repetition
      5. Floating-Point Number Precision and Memory Requirements
      6. Converting Between Fundamental Types Explicitly and Implicitly
      7. Formatting for Floating-Point Numbers
    10. 4.10. Formulating Algorithms: Nested Control Statements
      1. Conversion to Class Analysis
      2. Demonstrating Class Analysis
    11. 4.11. Assignment Operators
    12. 4.12. Increment and Decrement Operators
    13. 4.13. (Optional) Software Engineering Case Study: Identifying Class Attributes in the ATM System
      1. Identifying Attributes
      2. Modeling Attributes
      3. Software Engineering Case Study Self-Review Exercises
      4. Answers to Software Engineering Case Study Self-Review Exercises
    14. 4.14. Wrap-Up
    15. Summary
      1. Section 4.2 Algorithms
      2. Section 4.3 Pseudocode
      3. Section 4.4 Control Structures
      4. Section 4.5 if Selection Statement
      5. Section 4.6 if...else Double-Selection Statement
      6. Section 4.7 while Repetition Statement
      7. Section 4.8 Formulating Algorithms: Counter-Controlled Repetition
      8. Section 4.9 Formulating Algorithms: Sentinel-Controlled Repetition
      9. Section 4.10 Formulating Algorithms: Nested Control Statements
      10. Section 4.11 Assignment Operators
      11. Section 4.12 Increment and Decrement Operators
    16. Terminology
    17. Self-Review Exercises
    18. Answers to Self-Review Exercises
    19. Exercises
  12. 5. Control Statements: Part 2
    1. 5.1. Introduction
    2. 5.2. Essentials of Counter-Controlled Repetition
    3. 5.3. for Repetition Statement
      1. for Statement Header Components
      2. for Statement UML Activity Diagram
    4. 5.4. Examples Using the for Statement
      1. Application: Summing the Even Integers from 2 to 20
      2. Application: Compound Interest Calculations
      3. A Caution about Using Type float or double for Monetary Amounts
      4. Using Stream Manipulators to Format Numeric Output
    5. 5.5. do...while Repetition Statement
      1. do...while Statement UML Activity Diagram
    6. 5.6. switch Multiple-Selection Statement
      1. GradeBook Class with switch Statement to Count A, B, C, D and F Grades
      2. Reading Character Input
      3. switch Statement Details
      4. Providing a default Case
      5. Ignoring Newline, Tab and Blank Characters in Input
      6. Testing Class GradeBook
      7. switch Statement UML Activity Diagram
      8. Notes on Data Types
    7. 5.7. break and continue Statements
      1. break Statement
      2. continue Statement
    8. 5.8. Logical Operators
      1. Logical AND (&&) Operator
      2. Logical OR (||) Operator
      3. Logical Negation (!) Operator
      4. Logical Operators Example
      5. Summary of Operator Precedence and Associativity
    9. 5.9. Confusing the Equality (==) and Assignment (=) Operators
    10. 5.10. Structured Programming Summary
    11. 5.11. (Optional) Software Engineering Case Study: Identifying Objects’ States and Activities in the ATM System
      1. State Machine Diagrams
      2. Activity Diagrams
      3. Software Engineering Case Study Self-Review Exercises
      4. Answers to Software Engineering Case Study Self-Review Exercises
    12. 5.12. Wrap-Up
    13. Summary
      1. Section 5.2 Essentials of Counter-Controlled Repetition
      2. Section 5.3 for Repetition Statement
      3. Section 5.4 Examples Using the for Statement
      4. Section 5.5 do...while Repetition Statement
      5. Section 5.6 switch Multiple-Selection Statement
      6. Section 5.7 break and continue Statements
      7. Section 5.8 Logical Operators
      8. Section 5.9 Confusing the Equality (==) and Assignment (=) Operators
      9. Section 5.10 Structured Programming Summary
    14. Terminology
    15. Self-Review Exercises
    16. Answers to Self-Review Exercises
    17. Exercises
  13. 6. Functions and an Introduction to Recursion
    1. 6.1. Introduction
    2. 6.2. Program Components in C++
    3. 6.3. Math Library Functions
    4. 6.4. Function Definitions with Multiple Parameters
    5. 6.5. Function Prototypes and Argument Coercion
      1. Function Signatures
      2. Argument Coercion
      3. Argument Promotion Rules
    6. 6.6. C++ Standard Library Header Files
    7. 6.7. Case Study: Random Number Generation
      1. Rolling a Six-Sided Die
      2. Rolling a Six-Sided Die 6,000,000 Times
      3. Randomizing the Random Number Generator
      4. Generalized Scaling and Shifting of Random Numbers
    8. 6.8. Case Study: Game of Chance; Introducing enum
    9. 6.9. Storage Classes
      1. Storage Class, Scope and Linkage
      2. Storage Class Categories
      3. Local Variables
      4. Register Variables
      5. Static Storage Class
      6. Identifiers with Static Storage Class
    10. 6.10. Scope Rules
    11. 6.11. Function Call Stack and Activation Records
      1. Function Call Stack in Action
    12. 6.12. Functions with Empty Parameter Lists
    13. 6.13. Inline Functions
    14. 6.14. References and Reference Parameters
      1. Reference Parameters
      2. Passing Arguments by Value and by Reference
      3. References as Aliases within a Function
      4. Returning a Reference from a Function
      5. Error Messages for Uninitialized References
    15. 6.15. Default Arguments
    16. 6.16. Unary Scope Resolution Operator
    17. 6.17. Function Overloading
      1. Overloaded square Functions
      2. How the Compiler Differentiates Overloaded Functions
      3. Overloaded Operators
    18. 6.18. Function Templates
    19. 6.19. Recursion
    20. 6.20. Example Using Recursion: Fibonacci Series
    21. 6.21. Recursion vs. Iteration
    22. 6.22. (Optional) Software Engineering Case Study: Identifying Class Operations in the ATM System
      1. Identifying Operations
      2. Modeling Operations
      3. Operations of Class BankDatabase and Class Account
      4. Operations of Class Screen
      5. Operations of Class Keypad
      6. Operations of Class CashDispenser and Class DepositSlot
      7. Operations of Class ATM
      8. Identifying and Modeling Operation Parameters
      9. Software Engineering Case Study Self-Review Exercises
      10. Answers to Software Engineering Case Study Self-Review Exercises
    23. 6.23. Wrap-Up
    24. Summary
      1. Section 6.1 Introduction
      2. Section 6.2 Program Components in C++
      3. Section 6.3 Math Library Functions
      4. Section 6.4 Function Definitions with Multiple Parameters
      5. Section 6.5 Function Prototypes and Argument Coercion
      6. Section 6.6 C++ Standard Library Header Files
      7. Section 6.7 Case Study: Random Number Generation
      8. Section 6.8 Case Study: Game of Chance; Introducing enum
      9. Section 6.9 Storage Classes
      10. Section 6.10 Scope Rules
      11. Section 6.11 Function Call Stack and Activation Records
      12. Section 6.12 Functions with Empty Parameter Lists
      13. Section 6.13 Inline Functions
      14. Section 6.14 References and Reference Parameters
      15. Section 6.15 Default Arguments
      16. Section 6.16 Unary Scope Resolution Operator
      17. Section 6.17 Function Overloading
      18. Section 6.18 Function Templates
      19. Section 6.19 Recursion
      20. Section 6.20 Example Using Recursion: Fibonacci Series
      21. Section 6.21 Recursion vs. Iteration
    25. Terminology
    26. Self-Review Exercises
    27. Answers to Self-Review Exercises
    28. Exercises
  14. 7. Arrays and Vectors
    1. 7.1. Introduction
    2. 7.2. Arrays
    3. 7.3. Declaring Arrays
    4. 7.4. Examples Using Arrays
      1. 7.4.1. Declaring an Array and Using a Loop to Initialize the Array’s Elements
      2. 7.4.2. Initializing an Array in a Declaration with an Initializer List
      3. 7.4.3. Specifying an Array’s Size with a Constant Variable and Setting Array Elements with Calculations
      4. 7.4.4. Summing the Elements of an Array
      5. 7.4.5. Using Bar Charts to Display Array Data Graphically
      6. 7.4.6. Using the Elements of an Array as Counters
      7. 7.4.7. Using Arrays to Summarize Survey Results
      8. 7.4.8. Using Character Arrays to Store and Manipulate Strings
      9. 7.4.9. Static Local Arrays and Automatic Local Arrays
    5. 7.5. Passing Arrays to Functions
    6. 7.6. Case Study: Class GradeBook Using an Array to Store Grades
      1. Storing Student Grades in an Array in Class GradeBook
      2. Testing Class GradeBook
    7. 7.7. Searching Arrays with Linear Search
      1. Linear Search
    8. 7.8. Sorting Arrays with Insertion Sort
      1. Insertion Sort
    9. 7.9. Multidimensional Arrays
    10. 7.10. Case Study: Class GradeBook Using a Two-Dimensional Array
      1. Storing Student Grades in a Two-Dimensional Array in Class GradeBook
      2. Testing Class GradeBook
    11. 7.11. Introduction to C++ Standard Library Class Template vector
    12. 7.12. (Optional) Software Engineering Case Study: Collaboration Among Objects in the ATM System
      1. Identifying the Collaborations in a System
      2. Interaction Diagrams
      3. Communication Diagrams
      4. Sequence of Messages in a Communication Diagram
      5. Sequence Diagrams
      6. Software Engineering Case Study Self-Review Exercises
      7. Answers to Software Engineering Case Study Self-Review Exercises
    13. 7.13. Wrap-Up
    14. Summary
      1. Section 7.1 Introduction
      2. Section 7.2 Arrays
      3. Section 7.3 Declaring Arrays
      4. Section 7.4 Examples Using Arrays
      5. Section 7.5 Passing Arrays to Functions
      6. Section 7.6 Case Study: Class GradeBook Using an Array to Store Grades
      7. Section 7.7 Searching Arrays with Linear Search
      8. Section 7.8 Sorting Arrays with Insertion Sort
      9. Section 7.9 Multidimensional Arrays
      10. Section 7.11 Introduction to C++ Standard Library Class Template vector
    15. Terminology
    16. Self-Review Exercises
    17. Answers to Self-Review Exercises
    18. Exercises
    19. Recursion Exercises
    20. vector Exercises
  15. 8. Pointers and Pointer-Based Strings
    1. 8.1. Introduction
    2. 8.2. Pointer Variable Declarations and Initialization
    3. 8.3. Pointer Operators
    4. 8.4. Passing Arguments to Functions by Reference with Pointers
    5. 8.5. Using const with Pointers
      1. Nonconstant Pointer to Nonconstant Data
      2. Nonconstant Pointer to Constant Data
      3. Constant Pointer to Nonconstant Data
      4. Constant Pointer to Constant Data
    6. 8.6. Selection Sort Using Pass-by-Reference
    7. 8.7. sizeof Operator
      1. Determining the Sizes of the Fundamental Types, an Array and a Pointer
    8. 8.8. Pointer Expressions and Pointer Arithmetic
    9. 8.9. Relationship Between Pointers and Arrays
    10. 8.10. Arrays of Pointers
    11. 8.11. Case Study: Card Shuffling and Dealing Simulation
    12. 8.12. Function Pointers
      1. Multipurpose Selection Sort Using Function Pointers
      2. Arrays of Pointers to Functions
    13. 8.13. Introduction to Pointer-Based String Processing
      1. 8.13.1. Fundamentals of Characters and Pointer-Based Strings
      2. 8.13.2. String-Manipulation Functions of the String-Handling Library
        1. Copying Strings with strcpy and strncpy
        2. Concatenating Strings with strcat and strncat
        3. Comparing Strings with strcmp and strncmp
        4. Tokenizing a String with strtok
        5. Determining String Lengths
    14. 8.14. Wrap-Up
    15. Summary
      1. Section 8.2 Pointer Variable Declarations and Initialization
      2. Section 8.3 Pointer Operators
      3. Section 8.4 Passing Arguments to Functions by Reference with Pointers
      4. Section 8.5 Using const with Pointers
      5. Section 8.6 Selection Sort Using Pass-by-Reference
      6. Section 8.7 sizeof Operator
      7. Section 8.8 Pointer Expressions and Pointer Arithmetic
      8. Section 8.9 Relationship Between Pointers and Arrays
      9. Section 8.10 Arrays of Pointers
      10. Section 8.11 Case Study: Card Shuffling and Dealing Simulation
      11. Section 8.12 Function Pointers
      12. Section 8.13 Introduction to Pointer-Based String Processing
    16. Terminology
    17. Self-Review Exercises
    18. Answers to Self-Review Exercises
    19. Exercises
    20. Special Section: Building Your Own Computer
    21. More Pointer Exercises
    22. String-Manipulation Exercises
    23. Special Section: Advanced String-Manipulation Exercises
    24. A Challenging String-Manipulation Project
  16. 9. Classes: A Deeper Look, Part 1
    1. 9.1. Introduction
    2. 9.2. Time Class Case Study
      1. Time Class Definition
      2. Time Class Member Functions
      3. Defining Member Functions Outside the Class Definition; Class Scope
      4. Member Functions vs. Global Functions
      5. Using Class Time
      6. Looking Ahead to Composition and Inheritance
      7. Object Size
    3. 9.3. Class Scope and Accessing Class Members
    4. 9.4. Separating Interface from Implementation
    5. 9.5. Access Functions and Utility Functions
    6. 9.6. Time Class Case Study: Constructors with Default Arguments
      1. Notes Regarding Class Time’s Set and Get Functions and Constructor
    7. 9.7. Destructors
    8. 9.8. When Constructors and Destructors Are Called
    9. 9.9. Time Class Case Study: A Subtle Trap—Returning a Reference to a private Data Member
    10. 9.10. Default Memberwise Assignment
    11. 9.11. (Optional) Software Engineering Case Study: Starting to Program the Classes of the ATM System
      1. Visibility
      2. Navigability
      3. Implementing the ATM System from Its UML Design
      4. Software Engineering Case Study Self-Review Exercises
      5. Answers to Software Engineering Case Study Self-Review Exercises
    12. 9.12. Wrap-Up
    13. Summary
      1. Section 9.2 Time Class Case Study
      2. Section 9.3 Class Scope and Accessing Class Members
      3. Section 9.4 Separating Interface from Implementation
      4. Section 9.5 Access Functions and Utility Functions
      5. Section 9.6 Time Class Case Study: Constructors with Default Arguments
      6. Section 9.7 Destructors
      7. Section 9.8 When Constructors and Destructors Are Called
      8. Section 9.9 Time Class Case Study: A Subtle Trap—Returning a Reference to a private Data Member
      9. Section 9.10 Default Memberwise Assignment
    14. Terminology
    15. Self-Review Exercises
    16. Answers to Self-Review Exercises
    17. Exercises
  17. 10. Classes: A Deeper Look, Part 2
    1. 10.1. Introduction
    2. 10.2. const (Constant) Objects and const Member Functions
      1. Defining and Using const Member Functions
      2. Initializing a const Data Member with a Member Initializer
      3. Erroneously Attempting to Initialize a const Data Member with an Assignment
    3. 10.3. Composition: Objects as Members of Classes
    4. 10.4. friend Functions and friend Classes
      1. Modifying a Class’s private Data with a Friend Function
      2. Erroneously Attempting to Modify a private Member with a Non-friend Function
    5. 10.5. Using the this Pointer
      1. Implicitly and Explicitly Using the this Pointer to Access an Object’s Data Members
      2. Using the this Pointer to Enable Cascaded Function Calls
    6. 10.6. Dynamic Memory Management with Operators new and delete
    7. 10.7. static Class Members
    8. 10.8. Data Abstraction and Information Hiding
      1. 10.8.1. Example: Array Abstract Data Type
      2. 10.8.2. Example: String Abstract Data Type
      3. 10.8.3. Example: Queue Abstract Data Type
    9. 10.9. Container Classes and Iterators
    10. 10.10. Proxy Classes
    11. 10.11. Wrap-Up
    12. Summary
      1. Section 10.2 const (Constant) Objects and const Member Functions
      2. Section 10.3 Composition: Objects as Members of Classes
      3. Section 10.4 friend Functions and friend Classes
      4. Section 10.5 Using the this Pointer
      5. Section 10.6 Dynamic Memory Management with Operators new and delete
      6. Section 10.7 static Class Members
      7. Section 10.8 Data Abstraction and Information Hiding
      8. Section 10.9 Container Classes and Iterators
      9. Section 10.10 Proxy Classes
    13. Terminology
    14. Self-Review Exercises
    15. Answers to Self-Review Exercises
    16. Exercises
  18. 11. Operator Overloading; String and Array Objects
    1. 11.1. Introduction
    2. 11.2. Fundamentals of Operator Overloading
    3. 11.3. Restrictions on Operator Overloading
      1. Precedence, Associativity and Number of Operands
      2. Creating New Operators
      3. Operators for Fundamental Types
      4. Related Operators
    4. 11.4. Operator Functions as Class Members vs. Global Functions
      1. Operators That Must Be Overloaded as Member Functions
      2. Operators as Member Functions and Global Functions
      3. Why Overloaded Stream Insertion and Stream Extraction Operators Are Overloaded as Global Functions
      4. Commutative Operators
    5. 11.5. Overloading Stream Insertion and Stream Extraction Operators
    6. 11.6. Overloading Unary Operators
    7. 11.7. Overloading Binary Operators
    8. 11.8. Case Study: Array Class
      1. Creating Arrays, Outputting Their Size and Displaying Their Contents
      2. Using the Overloaded Stream Insertion Operator to Fill an Array
      3. Using the Overloaded Inequality Operator
      4. Initializing a New Array with a Copy of an Existing Array’s Contents
      5. Using the Overloaded Assignment Operator
      6. Using the Overloaded Equality Operator
      7. Using the Overloaded Subscript Operator
      8. Array Class Definition
      9. Overloading the Stream Insertion and Stream Extraction Operators as friends
      10. Array Default Constructor
      11. Array Copy Constructor
      12. Array Destructor
      13. getSize Member Function
      14. Overloaded Assignment Operator
      15. Overloaded Equality and Inequality Operators
      16. Overloaded Subscript Operators
    9. 11.9. Converting between Types
    10. 11.10. Case Study: String Class
      1. String Class Definition
      2. Overloading the Stream Insertion and Stream Extraction Operators as friends
      3. String Conversion Constructor
      4. String Copy Constructor
      5. String Destructor
      6. Overloaded Assignment Operator
      7. Overloaded Addition Assignment Operator
      8. Overloaded Negation Operator
      9. Overloaded Equality and Relational Operators
      10. Overloaded Subscript Operators
      11. Overloaded Function Call Operator
      12. String Member Function getLength
      13. Notes on Our String Class
    11. 11.11. Overloading ++ and --
      1. Overloading the Prefix Increment Operator
      2. Overloading the Postfix Increment Operator
    12. 11.12. Case Study: A Date Class
    13. 11.13. Standard Library Class string
      1. Standard Library Class string
    14. 11.14. explicit Constructors
      1. Accidentally Using a Single-Argument Constructor as a Conversion Constructor
      2. Preventing Accidental Use of a Single-Argument Constructor as a Conversion Constructor
    15. 11.15. Wrap-Up
    16. Summary
      1. Section 11.1 Introduction
      2. Section 11.2 Fundamentals of Operator Overloading
      3. Section 11.3 Restrictions on Operator Overloading
      4. Section 11.4 Operator Functions as Class Members vs. Global Functions
      5. Section 11.5 Overloading Stream Insertion and Stream Extraction Operators
      6. Section 11.6 Overloading Unary Operators
      7. Section 11.7 Overloading Binary Operators
      8. Section 11.8 Case Study: Array Class
      9. Section 11.9 Converting between Types
      10. Section 11.10 Case Study: String Class
      11. Section 11.11 Overloading ++ and --
      12. Section 11.13 Standard Library Class string
      13. Section 11.14 explicit Constructors
    17. Terminology
    18. Self-Review Exercises
    19. Answers to Self-Review Exercises
    20. Exercises
  19. 12. Object-Oriented Programming: Inheritance
    1. 12.1. Introduction
    2. 12.2. Base Classes and Derived Classes
    3. 12.3. protected Members
    4. 12.4. Relationship between Base Classes and Derived Classes
      1. 12.4.1. Creating and Using a CommissionEmployee Class
      2. 12.4.2. Creating a BasePlusCommissionEmployee Class Without Using Inheritance
        1. Defining Class BasePlusCommissionEmployee
        2. Testing Class BasePlusCommissionEmployee
        3. Exploring the Similarities Between Class BasePlusCommissionEmployee and Class CommissionEmployee
      3. 12.4.3. Creating a CommissionEmployee–BasePlusCommissionEmployee Inheritance Hierarchy
        1. Including the Base-Class Header File in the Derived-Class Header File with #include
        2. Linking Process in an Inheritance Hierarchy
      4. 12.4.4. CommissionEmployee–BasePlusCommissionEmployee Inheritance Hierarchy Using protected Data
        1. Defining Base Class CommissionEmployee with protected Data
        2. Modifying Derived Class BasePlusCommissionEmployee
        3. Testing the Modified BasePlusCommissionEmployee Class
        4. Notes on Using protected Data
      5. 12.4.5. CommissionEmployee–BasePlusCommissionEmployee Inheritance Hierarchy Using private Data
    5. 12.5. Constructors and Destructors in Derived Classes
    6. 12.6. public, protected and private Inheritance
    7. 12.7. Software Engineering with Inheritance
    8. 12.8. Wrap-Up
    9. Summary
      1. Section 12.1 Introduction
      2. Section 12.2 Base Classes and Derived Classes
      3. Section 12.3 protected Members
      4. Section 12.5 Constructors and Destructors in Derived Classes
      5. Section 12.6 public, protected and private Inheritance
    10. Terminology
    11. Self-Review Exercises
    12. Answers to Self-Review Exercises
    13. Exercises
  20. 13. Object-Oriented Programming: Polymorphism
    1. 13.1. Introduction
    2. 13.2. Polymorphism Examples
    3. 13.3. Relationships Among Objects in an Inheritance Hierarchy
      1. 13.3.1. Invoking Base-Class Functions from Derived-Class Objects
      2. 13.3.2. Aiming Derived-Class Pointers at Base-Class Objects
      3. 13.3.3. Derived-Class Member-Function Calls via Base-Class Pointers
      4. 13.3.4. Virtual Functions
      5. 13.3.5. Summary of the Allowed Assignments Between Base-Class and Derived-Class Objects and Pointers
    4. 13.4. Type Fields and switch Statements
    5. 13.5. Abstract Classes and Pure virtual Functions
    6. 13.6. Case Study: Payroll System Using Polymorphism
      1. 13.6.1. Creating Abstract Base Class Employee
      2. 13.6.2. Creating Concrete Derived Class SalariedEmployee
      3. 13.6.3. Creating Concrete Derived Class HourlyEmployee
      4. 13.6.4. Creating Concrete Derived Class CommissionEmployee
      5. 13.6.5. Creating Indirect Concrete Derived Class BasePlusCommissionEmployee
      6. 13.6.6. Demonstrating Polymorphic Processing
    7. 13.7. (Optional) Polymorphism, Virtual Functions and Dynamic Binding “Under the Hood”
    8. 13.8. Case Study: Payroll System Using Polymorphism and Runtime Type Information with Downcasting, dynamic_cast, typeid and type_info
    9. 13.9. Virtual Destructors
    10. 13.10. (Optional) Software Engineering Case Study: Incorporating Inheritance into the ATM System
      1. Implementing the ATM System Design Incorporating Inheritance
      2. ATM Case Study Wrap-Up
      3. Software Engineering Case Study Self-Review Exercises
      4. Answers to Software Engineering Case Study Self-Review Exercises
    11. 13.11. Wrap-Up
    12. Summary
      1. Section 13.1 Introduction
      2. Section 13.2 Polymorphism Examples
      3. Section 13.3 Relationships Among Objects in an Inheritance Hierarchy
      4. Section 13.4 Type Fields and switch Statements
      5. Section 13.5 Abstract Classes and Pure virtual Functions
      6. Section 13.7 (Optional) Polymorphism, Virtual Functions and Dynamic Binding “Under the Hood”
      7. Section 13.8 Case Study: Payroll System Using Polymorphism and Runtime Type Information with Downcasting, dynamic_cast, typeid and type_info
      8. Section 13.9 Virtual Destructors
    13. Terminology
    14. Self-Review Exercises
    15. Answers to Self-Review Exercises
    16. Exercises
  21. 14. Templates
    1. 14.1. Introduction
    2. 14.2. Function Templates
      1. Example: Function Template printArray
    3. 14.3. Overloading Function Templates
    4. 14.4. Class Templates
      1. Creating Class Template Stack< T >
      2. Creating a Driver to Test Class Template Stack< T >
      3. Creating Function Templates to Test Class Template Stack< T >
    5. 14.5. Nontype Parameters and Default Types for Class Templates
    6. 14.6. Notes on Templates and Inheritance
    7. 14.7. Notes on Templates and Friends
    8. 14.8. Notes on Templates and static Members
    9. 14.9. Wrap-Up
    10. Summary
      1. Section 14.1 Introduction
      2. Section 14.2 Function Templates
      3. Section 14.3 Overloading Function Templates
      4. Section 14.4 Class Templates
      5. Section 14.5 Nontype Parameters and Default Types for Class Templates
      6. Section 14.6 Notes on Templates and Inheritance
      7. Section 14.7 Notes on Templates and Friends
      8. Section 14.8 Notes on Templates and static Members
    11. Terminology
    12. Self-Review Exercises
    13. Answers to Self-Review Exercises
    14. Exercises
  22. 15. Stream Input/Output
    1. 15.1. Introduction
    2. 15.2. Streams
      1. 15.2.1. Classic Streams vs. Standard Streams
      2. 15.2.2. iostream Library Header Files
      3. 15.2.3. Stream Input/Output Classes and Objects
        1. Stream-I/O Template Hierarchy and Operator Overloading
        2. Standard Stream Objects cin, cout, cerr and clog
        3. File-Processing Templates
    3. 15.3. Stream Output
      1. 15.3.1. Output of char * Variables
      2. 15.3.2. Character Output Using Member Function put
    4. 15.4. Stream Input
      1. 15.4.1. get and getline Member Functions
        1. Using Member Functions eof, get and put
        2. Comparing cin and cin.get
        3. Using Member Function getline
      2. 15.4.2. istream Member Functions peek, putback and ignore
      3. 15.4.3. Type-Safe I/O
    5. 15.5. Unformatted I/O Using read, write and gcount
    6. 15.6. Introduction to Stream Manipulators
      1. 15.6.1. Integral Stream Base: dec, oct, hex and setbase
      2. 15.6.2. Floating-Point Precision (precision, setprecision)
      3. 15.6.3. Field Width (width, setw)
      4. 15.6.4. User-Defined Output Stream Manipulators
    7. 15.7. Stream Format States and Stream Manipulators
      1. 15.7.1. Trailing Zeros and Decimal Points (showpoint)
      2. 15.7.2. Justification (left, right and internal)
      3. 15.7.3. Padding (fill, setfill)
      4. 15.7.4. Integral Stream Base (dec, oct, hex, showbase)
      5. 15.7.5. Floating-Point Numbers; Scientific and Fixed Notation (scientific, fixed)
      6. 15.7.6. Uppercase/Lowercase Control (uppercase)
      7. 15.7.7. Specifying Boolean Format (boolalpha)
      8. 15.7.8. Setting and Resetting the Format State via Member Function flags
    8. 15.8. Stream Error States
    9. 15.9. Tying an Output Stream to an Input Stream
    10. 15.10. Wrap-Up
    11. Summary
      1. Section 15.1 Introduction
      2. Section 15.2 Streams
      3. Section 15.3 Stream Output
      4. Section 15.4 Stream Input
      5. Section 15.5 Unformatted I/O Using read, write and gcount
      6. Section 15.6 Introduction to Stream Manipulators
      7. Section 15.7 Stream Format States and Stream Manipulators
      8. Section 15.8 Stream Error States
      9. Section 15.9 Tying an Output Stream to an Input Stream
    12. Terminology
    13. Self-Review Exercises
    14. Answers to Self-Review Exercises
    15. Exercises
  23. 16. Exception Handling
    1. 16.1. Introduction
    2. 16.2. Exception-Handling Overview
    3. 16.3. Example: Handling an Attempt to Divide by Zero
      1. Defining an Exception Class to Represent the Type of Problem That Might Occur
      2. Demonstrating Exception Handling
      3. Enclosing Code in a try Block
      4. Defining a catch Handler to Process a DivideByZeroException
      5. Termination Model of Exception Handling
      6. Flow of Program Control When the User Enters a Nonzero Denominator
      7. Flow of Program Control When the User Enters a Denominator of Zero
    4. 16.4. When to Use Exception Handling
    5. 16.5. Rethrowing an Exception
    6. 16.6. Exception Specifications
    7. 16.7. Processing Unexpected Exceptions
    8. 16.8. Stack Unwinding
    9. 16.9. Constructors, Destructors and Exception Handling
    10. 16.10. Exceptions and Inheritance
    11. 16.11. Processing new Failures
      1. new Returning 0 on Failure
      2. new Throwing bad_alloc on Failure
      3. Handling new Failures Using Function set_new_handler
    12. 16.12. Class auto_ptr and Dynamic Memory Allocation
    13. 16.13. Standard Library Exception Hierarchy
    14. 16.14. Other Error-Handling Techniques
    15. 16.15. Wrap-Up
    16. Summary
      1. Section 16.1 Introduction
      2. Section 16.2 Exception-Handling Overview
      3. Section 16.3 Example: Handling an Attempt to Divide by Zero
      4. Section 16.4 When to Use Exception Handling
      5. Section 16.5 Rethrowing an Exception
      6. Section 16.6 Exception Specifications
      7. Section 16.7 Processing Unexpected Exceptions
      8. Section 16.8 Stack Unwinding
      9. Section 16.9 Constructors, Destructors and Exception Handling
      10. Section 16.10 Exceptions and Inheritance
      11. Section 16.11 Processing new Failures
      12. Section 16.12 Class auto_ptr and Dynamic Memory Allocation
      13. Section 16.13 Standard Library Exception Hierarchy
    17. Terminology
    18. Self-Review Exercises
    19. Answers to Self-Review Exercises
    20. Exercises
  24. 17. File Processing
    1. 17.1. Introduction
    2. 17.2. Data Hierarchy
    3. 17.3. Files and Streams
    4. 17.4. Creating a Sequential File
    5. 17.5. Reading Data from a Sequential File
    6. 17.6. Updating Sequential Files
    7. 17.7. Random-Access Files
    8. 17.8. Creating a Random-Access File
      1. Writing Bytes with ostream Member Function write
      2. Converting Between Pointer Types with the reinterpret_cast Operator
      3. Credit Processing Program
    9. 17.9. Writing Data Randomly to a Random-Access File
    10. 17.10. Reading from a Random-Access File Sequentially
    11. 17.11. Case Study: A Transaction-Processing Program
    12. 17.12. Overview of Object Serialization
    13. 17.13. Wrap-Up
    14. Summary
      1. Section 17.1 Introduction
      2. Section 17.2 Data Hierarchy
      3. Section 17.3 Files and Streams
      4. Section 17.4 Creating a Sequential File
      5. Section 17.5 Reading Data from a Sequential File
      6. Section 17.6 Updating Sequential Files
      7. Section 17.7 Random-Access Files
      8. Section 17.8 Creating a Random-Access File
      9. Section 17.9 Writing Data Randomly to a Random-Access File
      10. Section 17.10 Reading from a Random-Access File Sequentially
      11. Section 17.12 Overview of Object Serialization
    15. Terminology
    16. Self-Review Exercises
    17. Answers to Self-Review Exercises
    18. Exercises
  25. 18. Class string and String Stream Processing
    1. 18.1. Introduction
    2. 18.2. string Assignment and Concatenation
    3. 18.3. Comparing strings
    4. 18.4. Substrings
    5. 18.5. Swapping strings
    6. 18.6. string Characteristics
    7. 18.7. Finding Substrings and Characters in a string
    8. 18.8. Replacing Characters in a string
    9. 18.9. Inserting Characters into a string
    10. 18.10. Conversion to C-Style Pointer-Based char * Strings
    11. 18.11. Iterators
    12. 18.12. String Stream Processing
    13. 18.13. Wrap-Up
    14. Summary
      1. Section 18.1 Introduction
      2. Section 18.2 string Assignment and Concatenation
      3. Section 18.3 Comparing strings
      4. Section 18.4 Substrings
      5. Section 18.5 Swapping strings
      6. Section 18.6 string Characteristics
      7. Section 18.7 Finding Substrings and Characters in a string
      8. Section 18.8 Replacing Characters in a string
      9. Section 18.9 Inserting Characters into a string
      10. Section 18.10 Conversion to C-Style Pointer-Based char * Strings
      11. Section 18.11 Iterators
      12. Section 18.12 String Stream Processing
    15. Terminology
    16. Self-Review Exercises
    17. Answers to Self-Review Exercises
    18. Exercises
  26. 19. Searching and Sorting
    1. 19.1. Introduction
    2. 19.2. Searching Algorithms
      1. 19.2.1. Efficiency of Linear Search
      2. 19.2.2. Binary Search
        1. Efficiency of Binary Search
    3. 19.3. Sorting Algorithms
      1. 19.3.1. Efficiency of Selection Sort
      2. 19.3.2. Efficiency of Insertion Sort
      3. 19.3.3. Merge Sort (A Recursive Implementation)
        1. Efficiency of Merge Sort
    4. 19.4. Wrap-Up
    5. Summary
      1. Section 19.1 Introduction
      2. Section 19.2 Searching Algorithms
      3. Section 19.2.1 Efficiency of Linear Search
      4. Section 19.2.2 Binary Search
      5. Section 19.3.1 Efficiency of Selection Sort
      6. Section 19.3.2 Efficiency of Insertion Sort
      7. Section 19.3.3 Merge Sort (A Recursive Implementation)
    6. Terminology
    7. Self-Review Exercises
    8. Answers to Self-Review Exercises
    9. Exercises
  27. 20. Data Structures
    1. 20.1. Introduction
    2. 20.2. Self-Referential Classes
    3. 20.3. Dynamic Memory Allocation and Data Structures
    4. 20.4. Linked Lists
      1. Linked List Implementation
      2. Member Function insertAtFront
      3. Member Function insertAtBack
      4. Member Function removeFromFront
      5. Member Function removeFromBack
      6. Member Function print
      7. Linear and Circular Singly Linked and Doubly Linked Lists
    5. 20.5. Stacks
    6. 20.6. Queues
    7. 20.7. Trees
      1. Basic Terminology
      2. Binary Search Trees
      3. Implementing the Binary Search Tree Program
      4. Inorder Traversal Algorithm
      5. Preorder Traversal Algorithm
      6. Postorder Traversal Algorithm
      7. Duplicate Elimination
      8. Overview of the Binary Tree Exercises
    8. 20.8. Wrap-Up
    9. Summary
      1. Section 20.1 Introduction
      2. Section 20.2 Self-Referential Classes
      3. Section 20.3 Dynamic Memory Allocation and Data Structures
      4. Section 20.4 Linked Lists
      5. Section 20.5 Stacks
      6. Section 20.6 Queues
      7. Section 20.7 Trees
    10. Terminology
    11. Self-Review Exercises
    12. Answers to Self-Review Exercises
    13. Exercises
    14. Special Section: Building Your Own Compiler
  28. 21. Bits, Characters, C Strings and structs
    1. 21.1. Introduction
    2. 21.2. Structure Definitions
    3. 21.3. Initializing Structures
    4. 21.4. Using Structures with Functions
    5. 21.5. typedef
    6. 21.6. Example: High-Performance Card Shuffling and Dealing Simulation
    7. 21.7. Bitwise Operators
      1. Printing a Binary Representation of an Integral Value
      2. Bitwise AND Operator (&)
      3. Bitwise Inclusive OR Operator (|)
      4. Bitwise Exclusive OR (^)
      5. Bitwise Complement (~)
      6. Left-Shift Operator
      7. Right-Shift Operator
      8. Bitwise Assignment Operators
    8. 21.8. Bit Fields
    9. 21.9. Character-Handling Library
    10. 21.10. Pointer-Based String-Conversion Functions
    11. 21.11. Search Functions of the Pointer-Based String-Handling Library
    12. 21.12. Memory Functions of the Pointer-Based String-Handling Library
    13. 21.13. Wrap-Up
    14. Summary
      1. Section 21.2 Structure Definitions
      2. Section 21.3 Initializing Structures
      3. Section 21.4 Using Structures with Functions
      4. Section 21.5 typedef
      5. Section 21.7 Bitwise Operators
      6. Section 21.8 Bit Fields
      7. Section 21.9 Character-Handling Library
      8. Section 21.10 Pointer-Based String-Conversion Functions
      9. Section 21.11 Search Functions of the Pointer-Based String-Handling Library
      10. Section 21.12 Memory Functions of the Pointer-Based String-Handling Library
    15. Terminology
    16. Self-Review Exercises
    17. Answers to Self-Review Exercises
    18. Exercises
  29. 22. Standard Template Library (STL)
    1. 22.1. Introduction to the Standard Template Library (STL)
      1. 22.1.1. Introduction to Containers
        1. STL Containers Overview
        2. STL Container Common Functions
        3. STL Container Header Files
        4. First-Class Container Common typedefs
      2. 22.1.2. Introduction to Iterators
        1. Using istream_iterator for Input and Using ostream_iterator for Output
        2. Iterator Categories and Iterator Category Hierarchy
        3. Predefined Iterator typedefs
        4. Iterator Operations
      3. 22.1.3. Introduction to Algorithms
    2. 22.2. Sequence Containers
      1. 22.2.1. vector Sequence Container
        1. Using Vector and Iterators
        2. Vector Element-Manipulation Functions
      2. 22.2.2. list Sequence Container
      3. 22.2.3. deque Sequence Container
    3. 22.3. Associative Containers
      1. 22.3.1. multiset Associative Container
      2. 22.3.2. set Associative Container
      3. 22.3.3. multimap Associative Container
      4. 22.3.4. map Associative Container
    4. 22.4. Container Adapters
      1. 22.4.1. stack Adapter
      2. 22.4.2. queue Adapter
      3. 22.4.3. priority_queue Adapter
    5. 22.5. Algorithms
      1. 22.5.1. fill, fill_n, generate and generate_n
      2. 22.5.2. equal, mismatch and lexicographical_compare
      3. 22.5.3. remove, remove_if, remove_copy and remove_copy_if
      4. 22.5.4. replace, replace_if, replace_copy and replace_copy_if
      5. 22.5.5. Mathematical Algorithms
      6. 22.5.6. Basic Searching and Sorting Algorithms
      7. 22.5.7. swap, iter_swap and swap_ranges
      8. 22.5.8. copy_backward, merge, unique and reverse
      9. 22.5.9. inplace_merge, unique_copy and reverse_copy
      10. 22.5.10. Set Operations
      11. 22.5.11. lower_bound, upper_bound and equal_range
      12. 22.5.12. Heapsort
      13. 22.5.13. min and max
      14. 22.5.14. STL Algorithms Not Covered in This Chapter
    6. 22.6. Class bitset
      1. Sieve of Eratosthenes with bitset
    7. 22.7. Function Objects
      1. Predefined Function Objects of the Standard Template Library
      2. Using the STL Accumulate Algorithm
    8. 22.8. Wrap-Up
    9. 22.9. STL Web Resources
    10. Summary
      1. Section 22.1 Introduction to the Standard Template Library (STL)
      2. Section 22.1.1 Introduction to Containers
      3. Section 22.1.2 Introduction to Iterators
      4. Section 22.1.3 Introduction to Algorithms
      5. Section 22.2 Sequence Containers
      6. Section 22.2.1 vector Sequence Container
      7. Section 22.2.2 list Sequence Container
      8. Section 22.2.3 deque Sequence Container
      9. Section 22.3 Associative Containers
      10. Section 22.3.1 multiset Associative Container
      11. Section 22.3.2 set Associative Container
      12. Section 22.3.3 multimap Associative Container
      13. Section 22.3.4 map Associative Container
      14. Section 22.4 Container Adapters
      15. Section 22.4.1 stack Adapter
      16. Section 22.4.2 queue Adapter
      17. Section 22.4.3 priority_queue Adapter
      18. Section 22.5.1 fill, fill_n, generate and generate_n
      19. Section 22.5.2 equal, mismatch and lexicographical_compare
      20. Section 22.5.3 remove, remove_if, remove_copy and remove_copy_if
      21. Section 22.5.4 replace, replace_if, replace_copy and replace_copy_if
      22. Section 22.5.5 Mathematical Algorithms
      23. Section 22.5.6 Basic Searching and Sorting Algorithms
      24. Section 22.5.7 swap, iter_swap and swap_ranges
      25. Section 22.5.8 copy_backward, merge, unique and reverse
      26. Section 22.5.9 inplace_merge, unique_copy and reverse_copy
      27. Section 22.5.10 Set Operations
      28. Section 22.5.11 lower_bound, upper_bound and equal_range
      29. Section 22.5.12 Heapsort
      30. Section 22.5.13 min and max
      31. Section 22.6 Class bitset
      32. Section 22.7 Function Objects
    11. Terminology
    12. Self-Review Exercises
    13. Answers to Self-Review Exercises
    14. Exercises
    15. Recommended Reading
  30. 23. Game Programming with Ogre
    1. 23.1. Introduction
    2. 23.2. Installing Ogre, OgreAL and OpenAL
    3. 23.3. Basics of Game Programming
      1. Graphics
      2. 3D Models
      3. Materials, Textures and Colors
      4. Lighting
      5. Collision Detection and Response
      6. Sound
      7. Text
      8. Timers
      9. User Experience
    4. 23.4. The Game of Pong: Code Walkthrough
      1. 23.4.1. Ogre Initialization
      2. 23.4.2. Creating a Scene
        1. SceneManager
        2. Camera
        3. Light
      3. 23.4.3. Adding to the Scene
        1. Add the Ball
        2. Add the Paddles
        3. Add the Walls
        4. Add the Text
      4. 23.4.4. Animation and Timers
      5. 23.4.5. User Input
      6. 23.4.6. Collision Detection
      7. 23.4.7. Sound
      8. 23.4.8. Resources
      9. 23.4.9. Pong Driver
    5. 23.5. Wrap-Up
    6. 23.6. Ogre Web Resources
      1. Tutorials
      2. Tools
      3. Code Examples
      4. Books
      5. Forums
    7. Summary
      1. Section 23.3 Basics of Game Programming
      2. Section 23.4.1 Ogre Initialization
      3. Section 23.4.2 Creating a Scene
      4. Section 23.4.3 Adding to the Scene
      5. Section 23.4.4 Animation and Timers
      6. Section 23.4.5 User Input
      7. Section 23.4.6 Collision Detection
      8. Section 23.4.7 Sound
      9. Section 23.4.8 Resources
      10. Section 23.4.9 Pong Driver
    8. Terminology
    9. Self-Review Exercises
    10. Answers to Self-Review Exercises
    11. Exercises
  31. 24. Boost Libraries, Technical Report 1 and C++0x
    1. 24.1. Introduction
    2. 24.2. Deitel Online C++ and Related Resource Centers
    3. 24.3. Boost Libraries
    4. 24.4. Adding a New Library to Boost
      1. The Boost Software License
    5. 24.5. Installing the Boost Libraries
    6. 24.6. Boost Libraries in Technical Report 1 (TR1)
      1. Array
      2. Bind
      3. Function
      4. Mem_fn
      5. Random
      6. Ref
      7. Regex
      8. Result_of
      9. Smart_ptr
      10. Tuple
      11. Type_traits
    7. 24.7. Regular Expressions with the Boost.Regex Library
      1. Regular Expression Character Classes
      2. 24.7.1. Regular Expression Example
        1. Quantifiers
      3. 24.7.2. Validating User Input with Regular Expressions
      4. 24.7.3. Replacing and Splitting Strings
    8. 24.8. Smart Pointers with Boost.Smart_ptr
      1. 24.8.1. Reference Counted shared_ptr
        1. Example Using shared_ptr
      2. 24.8.2. weak_ptr: shared_ptr Observer
        1. Example Using weak_ptr
    9. 24.9. Technical Report 1
      1. Unordered Associative Containers
      2. Mathematical Special Functions
      3. Increased Compatibility with C99
    10. 24.10. C++0x
      1. Standardization Process
      2. Goals for C++0x
    11. 24.11. Core Language Changes
      1. Rvalue Reference
      2. Clarification of Initialization of Class Objects by rvalues
      3. static_assert
      4. extern template
      5. Extended friend Declarations
      6. Synchronizing the C++ Preprocessor with C99
      7. Conditionally Supported Behavior
      8. Changing Undefined Behavior into Diagnosable Errors
      9. Adding the long long Type to C++
      10. Adding Extended Integer Types to C++
      11. Delegating Constructors
      12. Right Angle Brackets
      13. Deducing the Type of Variable from Its Initializer
      14. Variadic Templates
      15. Template Aliases
      16. New Character Types
      17. Extending sizeof
      18. Alternative to Sequence Points
    12. 24.12. Wrap-Up
    13. Summary
      1. Section 24.2 Deitel Online C++ and Related Resource Centers
      2. Section 24.3 Boost Libraries
      3. Section 24.4 Adding a New Library to Boost
      4. Section 24.5 Installing the Boost Libraries
      5. Section 24.6 Boost Libraries in Technical Report 1 (TR1)
      6. Section 24.7 Regular Expressions with the Boost.Regex Library
      7. Section 24.7.1 Regular Expression Example
      8. Section 24.7.2 Validating User Input with Regular Expressions
      9. Section 24.7.3 Replacing and Splitting Strings
      10. Section 24.8 Smart Pointers with Boost.Smart_ptr
      11. Section 24.8.1 Reference Counted shared_ptr
      12. Section 24.8.2 weak_ptr:shared_ptr Observer
      13. Section 24.9 Technical Report 1
      14. Section 24.10 C++0x
      15. Section 24.11 Core Language Changes
    14. Terminology
    15. Self-Review Exercises
    16. Answers to Self-Review Exercises
    17. Exercises
  32. 25. Other Topics
    1. 25.1. Introduction
    2. 25.2. const_cast Operator
    3. 25.3. namespaces
      1. Using the std Namespace
      2. Defining Namespaces
      3. Accessing Namespace Members with Qualified Names
      4. Aliases for Namespace Names
    4. 25.4. Operator Keywords
    5. 25.5. mutable Class Members
      1. Mechanical Demonstration of a mutable Data Member
    6. 25.6. Pointers to Class Members (.* and ->*)
    7. 25.7. Multiple Inheritance
      1. Resolving Ambiguity Issues That Arise When a Derived Class Inherits Member Functions of the Same Name from Multiple Base Classes
      2. Demonstrating the Is-A Relationships in Multiple Inheritance
    8. 25.8. Multiple Inheritance and virtual Base Classes
      1. Compilation Errors Produced When Ambiguity Arises in Diamond Inheritance
      2. Eliminating Duplicate Subobjects with virtual Base-Class Inheritance
      3. Constructors in Multiple-Inheritance Hierarchies with virtual Base Classes
      4. Additional Information on Multiple Inheritance
    9. 25.9. Wrap-Up
    10. Summary
      1. Section 24.2 const_cast Operator
      2. Section 24.3 namespaces
      3. Section 25.4 Operator Keywords
      4. Section 24.5 mutable Class Members
      5. Section 24.6 Pointers to Class Members (.* and ->*)
      6. Section 25.7 Multiple Inheritance
      7. Section 24.8 Multiple Inheritance and virtual Base Classes
    11. Terminology
    12. Self-Review Exercises
    13. Answers to Self-Review Exercises
    14. Exercises
  33. A. Operator Precedence and Associativity Chart
    1. A.1. Operator Precedence
  34. B. ASCII Character Set
  35. C. Fundamental Types
  36. D. Number Systems
    1. D.1. Introduction
    2. D.2. Abbreviating Binary Numbers as Octal and Hexadecimal Numbers
    3. D.3. Converting Octal and Hexadecimal Numbers to Binary Numbers
    4. D.4. Converting from Binary, Octal or Hexadecimal to Decimal
    5. D.5. Converting from Decimal to Binary, Octal or Hexadecimal
    6. D.6. Negative Binary Numbers: Two’s Complement Notation
    7. Summary
    8. Terminology
    9. Self-Review Exercises
    10. Answers to Self-Review Exercises
    11. Exercises
  37. E. C Legacy Code Topics
    1. E.1. Introduction
    2. E.2. Redirecting Input/Output on UNIX/Linux/Mac OS X and Windows Systems
    3. E.3. Variable-Length Argument Lists
    4. E.4. Using Command-Line Arguments
    5. E.5. Notes on Compiling Multiple-Source-File Programs
    6. E.6. Program Termination with exit and atexit
    7. E.7. Type Qualifier volatile
    8. E.8. Suffixes for Integer and Floating-Point Constants
    9. E.9. Signal Handling
    10. E.10. Dynamic Memory Allocation with calloc and realloc
    11. E.11. Unconditional Branch: goto
    12. E.12. Unions
    13. E.13. Linkage Specifications
    14. E.14. Wrap-Up
    15. Summary
      1. Section E.2 Redirecting Input/Output on UNIX/Linux/Mac OS X and Windows Systems
      2. Section E.3 Variable-Length Argument Lists
      3. Section E.4 Using Command-Line Arguments
      4. Section E.5 Notes on Compiling Multiple-Source-File Programs
      5. Section E.6 Program Termination with exit and atexit
      6. Section E.7 Type Qualifier volatile
      7. Section E.8 Suffixes for Integer and Floating-Point Constants
      8. Section E.9 Signal Handling
      9. Section E.10 Dynamic Memory Allocation with calloc and realloc
      10. Section E.11 Unconditional Branch: goto
      11. Section E.12 Unions
      12. Section E.13 Linkage Specifications
    16. Terminology
    17. Self-Review Exercises
    18. Answers to Self-Review Exercises
    19. Exercises
  38. F. Preprocessor
    1. F.1. Introduction
    2. F.2. The #include Preprocessor Directive
    3. F.3. The #define Preprocessor Directive: Symbolic Constants
    4. F.4. The #define Preprocessor Directive: Macros
    5. F.5. Conditional Compilation
    6. F.6. The #error and #pragma Preprocessor Directives
    7. F.7. Operators # and ##
    8. F.8. Predefined Symbolic Constants
    9. F.9. Assertions
    10. F.10. Wrap-Up
    11. Summary
      1. Section F.2 The #include Preprocessor Directive
      2. Section F.3 The #define Preprocessor Directive: Symbolic Constants
      3. Section F.4 The #define Preprocessor Directive: Macros
      4. Section F.5 Conditional Compilation
      5. Section F.6 The #error and #pragma Preprocessor Directives
      6. Section F.7 Operators # and ##
      7. Section F.8 Predefined Symbolic Constants
      8. Section F.9 Assertions
    12. Terminology
    13. Self-Review Exercises
    14. Answers to Self-Review Exercises
    15. Exercises
  39. G. ATM Case Study Code
    1. G.1. ATM Case Study Implementation
    2. G.2. Class ATM
      1. ATM Class Member-Function Definitions
    3. G.3. Class Screen
      1. Screen Class Member-Function Definitions
    4. G.4. Class Keypad
      1. Keypad Class Member-Function Definition
    5. G.5. Class CashDispenser
      1. CashDispenser Class Member-Function Definitions
    6. G.6. Class DepositSlot
    7. G.7. Class Account
      1. Account Class Member-Function Definitions
    8. G.8. Class BankDatabase
      1. BankDatabase Class Member-Function Definitions
    9. G.9. Class Transaction
    10. G.10. Class BalanceInquiry
    11. G.11. Class Withdrawal
      1. Withdrawal Class Member-Function Definitions
    12. G.12. Class Deposit
      1. Deposit Class Member-Function Definitions
    13. G.13. Test Program ATMCaseStudy.cpp
    14. G.14. Wrap-Up
  40. H. UML 2: Additional Diagram Types
    1. H.1. Introduction
    2. H.2. Additional Diagram Types
  41. I. Using the Visual Studio Debugger
    1. I.1. Introduction
    2. I.2. Breakpoints and the Continue Command
    3. I.3. Locals and Watch Windows
    4. I.4. Controlling Execution Using the Step Into, Step Over, Step Out and Continue Commands
    5. I.5. Autos Window
    6. I.6. Wrap-Up
    7. Summary
      1. Section I.1 Introduction
      2. Section I.2 Breakpoints and the Continue Command
      3. Section I.3 Locals and Watch Windows
      4. Section I.4 Controlling Execution Using the Step Into, Step Over, Step Out and Continue Commands
      5. Section I.5 Autos Window
    8. Terminology
    9. Self-Review Exercises
    10. Answers to Self-Review Exercises
  42. J. Using the GNU C++ Debugger
    1. J.1. Introduction
    2. J.2. Breakpoints and the run, stop, continue and print Commands
    3. J.3. print and set Commands
    4. J.4. Controlling Execution Using the step, finish and next Commands
    5. J.5. watch Command
    6. J.6. Wrap-Up
    7. Summary
      1. Section J.1 Introduction
      2. Section J.2 Breakpoints and the run, stop, continue and print Commands
      3. Section J.3 print and set Commands
      4. Section J.4 Controlling Execution Using the step, finish and next Commands
      5. Section J.5 watch Command
    8. Terminology
    9. Self-Review Exercises
    10. Answers to Self-Review Exercises
  43. Bibliography