Professional C++

Book description

  • Geared to experienced C++ developers who may not be familiar with the more advanced features of the language, and therefore are not using it to its full capabilities

  • Teaches programmers how to think in C++-that is, how to design effective solutions that maximize the power of the language

  • The authors drill down into this notoriously complex language, explaining poorly understood elements of the C++ feature set as well as common pitfalls to avoid

  • Contains several in-depth case studies with working code that's been tested on Windows, Linux, and Solaris platforms

Table of contents

  1. Copyright
  2. Acknowledgments
  3. Author Bios
  4. Credits
  5. Introduction
    1. Who This Book Is For
    2. What This Book Covers
    3. How This Book Is Structured
    4. What You Need to Use This Book
    5. Conventions
    6. Source Code
    7. Errata
    8. p2p.wrox.com
  6. 1. A Crash Course in C++
    1. 1.1. The Basics of C++
      1. 1.1.1. The Obligatory Hello, World
        1. 1.1.1.1. Comments
        2. 1.1.1.2. Preprocessor Directives
        3. 1.1.1.3. The main function
        4. 1.1.1.4. I/O Streams
      2. 1.1.2. Namespaces
      3. 1.1.3. Variables
      4. 1.1.4. Operators
      5. 1.1.5. Types
        1. 1.1.5.1. Enumerated Types
        2. 1.1.5.2. Structs
      6. 1.1.6. Conditionals
        1. 1.1.6.1. If/Else Statements
        2. 1.1.6.2. Switch Statements
        3. 1.1.6.3. The Ternary Operator
        4. 1.1.6.4. Conditional Operators
      7. 1.1.7. Loops
        1. 1.1.7.1. The While Loop
        2. 1.1.7.2. The Do/While Loop
        3. 1.1.7.3. The For Loop
        4. 1.1.7.4. Arrays
      8. 1.1.8. Functions
      9. 1.1.9. Those Are the Basics
    2. 1.2. Diving Deeper into C++
      1. 1.2.1. Pointers and Dynamic Memory
        1. 1.2.1.1. The Stack and the Heap
        2. 1.2.1.2. Dynamically Allocated Arrays
        3. 1.2.1.3. Working with Pointers
      2. 1.2.2. Strings in C++
        1. 1.2.2.1. C-Style Strings
        2. 1.2.2.2. C++ Strings
        3. 1.2.2.3. Nonstandard Strings
      3. 1.2.3. References
      4. 1.2.4. Exceptions
      5. 1.2.5. The Many Uses of const
        1. 1.2.5.1. Const Constants
        2. 1.2.5.2. Const to Protect Variables
        3. 1.2.5.3. Const References
    3. 1.3. C++ as an Object-Oriented Language
      1. 1.3.1. Declaring a Class
    4. 1.4. Your First Useful C++ Program
      1. 1.4.1. An Employee Records System
      2. 1.4.2. The Employee Class
        1. 1.4.2.1. Employee.h
        2. 1.4.2.2. Employee.cpp
        3. 1.4.2.3. EmployeeTest.cpp
      3. 1.4.3. The Database Class
        1. 1.4.3.1. Database.h
        2. 1.4.3.2. Database.cpp
        3. 1.4.3.3. DatabaseTest.cpp
      4. 1.4.4. The User Interface
        1. 1.4.4.1. Userinterface.cpp
      5. 1.4.5. Evaluating the Program
    5. 1.5. Summary
  7. 2. Designing Professional C++ Programs
    1. 2.1. What Is Programming Design?
    2. 2.2. The Importance of Programming Design
    3. 2.3. What's Different about C++ Design?
    4. 2.4. Two Rules for C++ Design
      1. 2.4.1. Abstraction
        1. 2.4.1.1. Benefiting from Abstraction
        2. 2.4.1.2. Incorporating Abstraction in Your Design
      2. 2.4.2. Reuse
        1. 2.4.2.1. Reusing Code
        2. 2.4.2.2. Writing Reusable Code
        3. 2.4.2.3. Reusing Ideas
    5. 2.5. Designing a Chess Program
      1. 2.5.1. Requirements
      2. 2.5.2. Design Steps
        1. 2.5.2.1. Divide the Program into Subsystems
        2. 2.5.2.2. Choose Threading Models
        3. 2.5.2.3. Specify Class Hierarchies for Each Subsystem
        4. 2.5.2.4. Specify Classes, Data Structures, Algorithms, and Patterns for Each Subsystem
        5. 2.5.2.5. Specify Error Handling for Each Subsystem
    6. 2.6. Summary
  8. 3. Designing with Objects
    1. 3.1. An Object-Oriented View of the World
      1. 3.1.1. Am I Thinking Procedurally?
      2. 3.1.2. The Object-Oriented Philosophy
        1. 3.1.2.1. Classes
        2. 3.1.2.2. Components
        3. 3.1.2.3. Properties
        4. 3.1.2.4. Behaviors
        5. 3.1.2.5. Bringing It All Together
      3. 3.1.3. Living in a World of Objects
        1. 3.1.3.1. Overobjectification
        2. 3.1.3.2. Overly General Objects
      4. 3.1.4. Object Relationships
        1. 3.1.4.1. The Has-A Relationship
        2. 3.1.4.2. The Is-A Relationship (Inheritance)
          1. 3.1.4.2.1. Inheritance Techniques
          2. 3.1.4.2.2. Adding Functionality
          3. 3.1.4.2.3. Replacing Functionality
          4. 3.1.4.2.4. Adding Properties
          5. 3.1.4.2.5. Replacing Properties
          6. 3.1.4.2.6. Polymorphism versus Code Reuse
        3. 3.1.4.3. The Fine Line between Has-A and Is-A
        4. 3.1.4.4. The Not-A Relationship
        5. 3.1.4.5. Hierarchies
        6. 3.1.4.6. Multiple Inheritance
          1. 3.1.4.6.1. What's Bad about Multiple Inheritance?
        7. 3.1.4.7. Mix-in Classes
      5. 3.1.5. Abstraction
        1. 3.1.5.1. Interface versus Implementation
        2. 3.1.5.2. Deciding on an Exposed Interface
          1. 3.1.5.2.1. Consider the Audience
          2. 3.1.5.2.2. Consider the Purpose
          3. 3.1.5.2.3. Application Programming Interface (API)
          4. 3.1.5.2.4. Utility Class or Library
          5. 3.1.5.2.5. Subsystem Interface
          6. 3.1.5.2.6. Component Interface
          7. 3.1.5.2.7. Consider the Future
        3. 3.1.5.3. Designing a Successful Abstraction
    2. 3.2. Summary
  9. 4. Designing with Libraries and Patterns
    1. 4.1. Reusing Code
      1. 4.1.1. A Note on Terminology
      2. 4.1.2. Deciding Whether or Not to Reuse Code
        1. 4.1.2.1. Advantages to Reusing Code
        2. 4.1.2.2. Disadvantages to Reusing Code
        3. 4.1.2.3. Putting It Together to Make a Decision
      3. 4.1.3. Strategies for Reusing Code
        1. 4.1.3.1. Understand the Capabilities and Limitations
        2. 4.1.3.2. Understand the Performance
          1. 4.1.3.2.1. Big-O Notation
          2. 4.1.3.2.2. Tips for Understanding Performance
        3. 4.1.3.3. Understand Platform Limitations
        4. 4.1.3.4. Understand Licensing and Support
        5. 4.1.3.5. Know Where to Find Help
        6. 4.1.3.6. Prototype
      4. 4.1.4. Bundling Third-Party Applications
      5. 4.1.5. Open-Source Libraries
        1. 4.1.5.1. The Open-Source Movements
        2. 4.1.5.2. Finding and Using Open-Source Libraries
        3. 4.1.5.3. Guidelines for Using Open-Source Code
      6. 4.1.6. The C++ Standard Library
        1. 4.1.6.1. C Standard Library
        2. 4.1.6.2. Strings
        3. 4.1.6.3. I/O Streams
        4. 4.1.6.4. Internationalization
        5. 4.1.6.5. Smart Pointers
        6. 4.1.6.6. Exceptions
        7. 4.1.6.7. Mathematical Utilities
        8. 4.1.6.8. The Standard Template Library
          1. 4.1.6.8.1. STL Containers
          2. 4.1.6.8.2. Vector
          3. 4.1.6.8.3. List
          4. 4.1.6.8.4. Deque
          5. 4.1.6.8.5. Queue
          6. 4.1.6.8.6. Priority Queue
          7. 4.1.6.8.7. Stack
          8. 4.1.6.8.8. Set and Multiset
          9. 4.1.6.8.9. Map and Multimap
          10. 4.1.6.8.10. Bitset
          11. 4.1.6.8.11. Summary of STL Containers
        9. 4.1.6.9. STL Algorithms
          1. 4.1.6.9.1. Utility Algorithms
          2. 4.1.6.9.2. Nonmodifying Algorithms
          3. 4.1.6.9.3. Search Algorithms
          4. 4.1.6.9.4. Numerical Processing Algorithms
          5. 4.1.6.9.5. Comparison Algorithms
          6. 4.1.6.9.6. Operational Algorithms
          7. 4.1.6.9.7. Modifying Algorithms
          8. 4.1.6.9.8. Sorting Algorithms
          9. 4.1.6.9.9. Set Algorithms
          10. 4.1.6.9.10. Choosing an Algorithm
        10. 4.1.6.10. What's Missing from the STL
        11. 4.1.6.11. Deciding Whether or Not to Use the STL
    2. 4.2. Designing with Patterns and Techniques
      1. 4.2.1. Design Techniques
        1. 4.2.1.1. A Design Technique Example: Smart Pointers
      2. 4.2.2. Design Patterns
        1. 4.2.2.1. A Design Pattern Example: Iterator
    3. 4.3. Summary
  10. 5. Designing for Reuse
    1. 5.1. The Reuse Philosophy
    2. 5.2. How to Design Reusable Code
      1. 5.2.1. Use Abstraction
      2. 5.2.2. Structure Your Code for Optimal Reuse
        1. 5.2.2.1. Avoid Combining Unrelated or Logically Separate Concepts
          1. 5.2.2.1.1. Divide Your Programs into Logical Subsystems
          2. 5.2.2.1.2. Use Class Hierarchies to Separate Logical Concepts
          3. 5.2.2.1.3. Use Aggregation to Separate Logical Concepts
        2. 5.2.2.2. Use Templates for Generic Data Structures and Algorithms
          1. 5.2.2.2.1. Why Templates Are Better Than Other Generic Programming Techniques
          2. 5.2.2.2.2. Problems with Templates
          3. 5.2.2.2.3. Templates versus Inheritance
        3. 5.2.2.3. Provide Appropriate Checks and Safeguards
      3. 5.2.3. Design Usable Interfaces
        1. 5.2.3.1. Design Interfaces That Are Easy to Use
          1. 5.2.3.1.1. Develop Intuitive Interfaces
          2. 5.2.3.1.2. Don't Omit Required Functionality
          3. 5.2.3.1.3. Present Uncluttered Interfaces
          4. 5.2.3.1.4. Provide Documentation and Comments
        2. 5.2.3.2. Design General-Purpose Interfaces
          1. 5.2.3.2.1. Provide Multiple Ways to Perform the Same Functionality
          2. 5.2.3.2.2. Provide Customizability
      4. 5.2.4. Reconciling Generality and Ease of Use
        1. 5.2.4.1. Supply Multiple Interfaces
        2. 5.2.4.2. Optimize the Common Functionality
    3. 5.3. Summary
  11. 6. Maximizing Software-Engineering Methods
    1. 6.1. The Need for Process
    2. 6.2. Software Life-Cycle Models
      1. 6.2.1. The Stagewise and Waterfall Models
        1. 6.2.1.1. Benefits of the Waterfall Model
        2. 6.2.1.2. Drawbacks of the Waterfall Model
      2. 6.2.2. The Spiral Method
        1. 6.2.2.1. Benefits of the Spiral Method
        2. 6.2.2.2. Drawbacks of the Spiral Method
      3. 6.2.3. The Rational Unified Process
        1. 6.2.3.1. RUP as a Product
        2. 6.2.3.2. RUP as a Process
        3. 6.2.3.3. RUP in Practice
    3. 6.3. Software-Engineering Methodologies
      1. 6.3.1. Extreme Programming (XP)
        1. 6.3.1.1. XP in Theory
          1. 6.3.1.1.1. Plan as You Go
          2. 6.3.1.1.2. Build Small Releases
          3. 6.3.1.1.3. Share a Common Metaphor
          4. 6.3.1.1.4. Simplify Your Designs
          5. 6.3.1.1.5. Test Constantly
          6. 6.3.1.1.6. Refactor When Necessary
          7. 6.3.1.1.7. Code in Pairs
          8. 6.3.1.1.8. Share the Code
          9. 6.3.1.1.9. Integrate Continuously
          10. 6.3.1.1.10. Work Sane Hours
          11. 6.3.1.1.11. Have a Customer on Site
          12. 6.3.1.1.12. Share Common Coding Standards
        2. 6.3.1.2. XP in Practice
      2. 6.3.2. Software Triage
    4. 6.4. Building Your Own Process and Methodology
      1. 6.4.1. Be Open to New Ideas
      2. 6.4.2. Bring New Ideas to the Table
      3. 6.4.3. Recognize What Works and What Doesn't Work
      4. 6.4.4. Don't Be a Renegade
    5. 6.5. Summary
  12. 7. Coding with Style
    1. 7.1. The Importance of Looking Good
      1. 7.1.1. Thinking Ahead
      2. 7.1.2. Keeping It Clear
      3. 7.1.3. Elements of Good Style
    2. 7.2. Documenting Your Code
      1. 7.2.1. Reasons to Write Comments
        1. 7.2.1.1. Commenting to Explain Usage
        2. 7.2.1.2. Commenting to Explain Complicated Code
        3. 7.2.1.3. Commenting to Convey Metainformation
      2. 7.2.2. Commenting Styles
        1. 7.2.2.1. Commenting Every Line
        2. 7.2.2.2. Prefix Comments
        3. 7.2.2.3. Fixed-Format Comments
        4. 7.2.2.4. Ad Hoc Comments
        5. 7.2.2.5. Self-Documenting Code
      3. 7.2.3. Comments in This Book
    3. 7.3. Decomposition
      1. 7.3.1. Decomposition through Refactoring
      2. 7.3.2. Decomposition by Design
      3. 7.3.3. Decomposition in This Book
    4. 7.4. Naming
      1. 7.4.1. Choosing a Good Name
      2. 7.4.2. Naming Conventions
        1. 7.4.2.1. Counters
        2. 7.4.2.2. Getters and Setters
        3. 7.4.2.3. Prefixes
        4. 7.4.2.4. Capitalization
        5. 7.4.2.5. Smart Constants
        6. 7.4.2.6. Hungarian Notation
    5. 7.5. Using Language Features with Style
      1. 7.5.1. Use Constants
      2. 7.5.2. Take Advantage of const Variables
      3. 7.5.3. Use References Instead of Pointers
      4. 7.5.4. Use Custom Exceptions
    6. 7.6. Formatting
      1. 7.6.1. The Curly Brace Alignment Debate
      2. 7.6.2. Coming to Blows over Spaces and Parentheses
        1. 7.6.2.1. Spaces and Tabs
    7. 7.7. Stylistic Challenges
    8. 7.8. Summary
  13. 8. Gaining Proficiency with Classes and Objects
    1. 8.1. Introducing the Spreadsheet Example
    2. 8.2. Writing Classes
      1. 8.2.1. Class Definitions
        1. 8.2.1.1. Methods and Members
        2. 8.2.1.2. Access Control
        3. 8.2.1.3. Order of Declarations
      2. 8.2.2. Defining Methods
        1. 8.2.2.1. Accessing Data Members
        2. 8.2.2.2. Calling Other Methods
        3. 8.2.2.3. The this Pointer
      3. 8.2.3. Using Objects
        1. 8.2.3.1. Objects on the Stack
        2. 8.2.3.2. Objects on the Heap
    3. 8.3. Object Life Cycles
      1. 8.3.1. Object Creation
        1. 8.3.1.1. Writing Constructors
        2. 8.3.1.2. Using Constructors
          1. 8.3.1.2.1. Constructors on the Stack
          2. 8.3.1.2.2. Constructors on the Heap
        3. 8.3.1.3. Providing Multiple Constructors
        4. 8.3.1.4. Default Constructors
          1. 8.3.1.4.1. Compiler-Generated Default Constructor
          2. 8.3.1.4.2. When You Need a Default Constructor
        5. 8.3.1.5. Initializer Lists
        6. 8.3.1.6. Copy Constructors
          1. 8.3.1.6.1. When the Copy Constructor Is Called
          2. 8.3.1.6.2. Calling the Copy Constructor Explicitly
          3. 8.3.1.6.3. Passing Objects by Reference
        7. 8.3.1.7. Summary of Compiler-Generated Constructors
      2. 8.3.2. Object Destruction
      3. 8.3.3. Assigning to Objects
        1. 8.3.3.1. Declaring an Assignment Operator
        2. 8.3.3.2. Defining an Assignment Operator
      4. 8.3.4. Distinguishing Copying from Assignment
        1. 8.3.4.1. Objects as Return Values
        2. 8.3.4.2. Copy Constructors and Object Members
    4. 8.4. Summary
  14. 9. Mastering Classes and Objects
    1. 9.1. Dynamic Memory Allocation in Objects
      1. 9.1.1. The Spreadsheet Class
      2. 9.1.2. Freeing Memory with Destructors
      3. 9.1.3. Handling Copying and Assignment
        1. 9.1.3.1. The Spreadsheet Copy Constructor
        2. 9.1.3.2. The Spreadsheet Assignment Operator
        3. 9.1.3.3. Common Helper Routines for Copy Constructor and Assignment Operator
        4. 9.1.3.4. Disallowing Assignment and Pass-By-Value
    2. 9.2. Different Kinds of Data Members
      1. 9.2.1. Static Data Members
        1. 9.2.1.1. Accessing Static Data Members within Class Methods
        2. 9.2.1.2. Accessing Static Data Members Outside Methods
      2. 9.2.2. Const Data Members
      3. 9.2.3. Reference Data Members
      4. 9.2.4. Const Reference Data Members
    3. 9.3. More about Methods
      1. 9.3.1. Static Methods
      2. 9.3.2. Const Methods
        1. 9.3.2.1. Mutable Data Members
      3. 9.3.3. Method Overloading
      4. 9.3.4. Default Parameters
      5. 9.3.5. Inline Methods
    4. 9.4. Nested Classes
    5. 9.5. Friends
    6. 9.6. Operator Overloading
      1. 9.6.1. Implementing Addition
        1. 9.6.1.1. First Attempt: The add Method
        2. 9.6.1.2. Second Attempt: Overloaded operator+ as a Method
          1. 9.6.1.2.1. Implicit Conversions
        3. 9.6.1.3. Third Attempt: Global Operator+
      2. 9.6.2. Overloading Arithmetic Operators
        1. 9.6.2.1. Overloading the Arithmetic Shorthand Operators
      3. 9.6.3. Overloading Comparison Operators
      4. 9.6.4. Building Types with Operator Overloading
    7. 9.7. Pointers to Methods and Members
    8. 9.8. Building Abstract Classes
      1. 9.8.1. Using Interface and Implementation Classes
    9. 9.9. Summary
  15. 10. Discovering Inheritance Techniques
    1. 10.1. Building Classes with Inheritance
      1. 10.1.1. Extending Classes
        1. 10.1.1.1. Clients' View of Inheritance
        2. 10.1.1.2. Subclass's View of Inheritance
      2. 10.1.2. Overriding Methods
        1. 10.1.2.1. How I Learned to Stop Worrying and Make Everything virtual
        2. 10.1.2.2. Syntax for Overriding a Method
        3. 10.1.2.3. Clients' View of Overridden Methods
    2. 10.2. Inheritance for Reuse
      1. 10.2.1. The WeatherPrediction Class
      2. 10.2.2. Adding Functionality in a Subclass
      3. 10.2.3. Replacing Functionality in a Subclass
    3. 10.3. Respect Your Parents
      1. 10.3.1. Parent Constructors
      2. 10.3.2. Parent Destructors
      3. 10.3.3. Referring to Parent Data
      4. 10.3.4. Casting Up and Down
    4. 10.4. Inheritance for Polymorphism
      1. 10.4.1. Return of the Spreadsheet
      2. 10.4.2. Designing the Polymorphic Spreadsheet Cell
      3. 10.4.3. The Spreadsheet Cell Base Class
        1. 10.4.3.1. A First Attempt
        2. 10.4.3.2. Pure Virtual Methods and Abstract Base Classes
        3. 10.4.3.3. Base Class Source Code
      4. 10.4.4. The Individual Subclasses
        1. 10.4.4.1. String Spreadsheet Cell Class Definition
        2. 10.4.4.2. String Spreadsheet Cell Implementation
        3. 10.4.4.3. Double Spreadsheet Cell Class Definition and Implementation
      5. 10.4.5. Leveraging Polymorphism
      6. 10.4.6. Future Considerations
    5. 10.5. Multiple Inheritance
      1. 10.5.1. Inheriting from Multiple Classes
      2. 10.5.2. Naming Collisions and Ambiguous Base Classes
        1. 10.5.2.1. Name Ambiguity
        2. 10.5.2.2. Ambiguous Base Classes
        3. 10.5.2.3. Uses for Multiple Inheritance
    6. 10.6. Interesting and Obscure Inheritance Issues
      1. 10.6.1. Changing the Overridden Method's Characteristics
        1. 10.6.1.1. Changing the Method Return Type
        2. 10.6.1.2. Changing the Method Parameters
      2. 10.6.2. Special Cases in Overriding Methods
        1. 10.6.2.1. If the Superclass Method Is Static
        2. 10.6.2.2. If the Superclass Method Is Overloaded
        3. 10.6.2.3. If the Superclass Method Is Private or Protected
        4. 10.6.2.4. If the Superclass Method Has Default Arguments
        5. 10.6.2.5. If the Superclass Method Has a Different Access Level
      3. 10.6.3. Copy Constructors and the Equals Operator
      4. 10.6.4. The Truth about Virtual
        1. 10.6.4.1. Hiding Instead of Overriding
        2. 10.6.4.2. How virtual Is Implemented
        3. 10.6.4.3. The Justification for virtual
        4. 10.6.4.4. The Horror of Non-virtual Destructors
      5. 10.6.5. Runtime Type Facilities
        1. 10.6.5.1. dynamic_cast
        2. 10.6.5.2. typeid
      6. 10.6.6. Non-Public Inheritance
      7. 10.6.7. Virtual Base Classes
    7. 10.7. Summary
  16. 11. Writing Generic Code with Templates
    1. 11.1. Overview of Templates
    2. 11.2. Class Templates
      1. 11.2.1. Writing a Class Template
        1. 11.2.1.1. Coding without Templates
        2. 11.2.1.2. A Template Grid Class
          1. 11.2.1.2.1. The Grid Class Definition
          2. 11.2.1.2.2. The Grid Class Method Definitions
        3. 11.2.1.3. Using the Grid Template
      2. 11.2.2. How the Compiler Processes Templates
        1. 11.2.2.1. Selective Instantiation
        2. 11.2.2.2. Template Requirements on Types
      3. 11.2.3. Distributing Template Code between Files
        1. 11.2.3.1. Template Definitions in Header Files
        2. 11.2.3.2. Template Definitions in Source Files
      4. 11.2.4. Template Parameters
        1. 11.2.4.1. Nontype Template Parameters
        2. 11.2.4.2. Default Values for Integer Nontype Parameters
      5. 11.2.5. Method Templates
        1. 11.2.5.1. Method Templates with Nontype Parameters
      6. 11.2.6. Template Class Specialization
      7. 11.2.7. Subclassing Template Classes
      8. 11.2.8. Inheritance versus Specialization
    3. 11.3. Function Templates
      1. 11.3.1. Function Template Specialization
      2. 11.3.2. Function Template Overloading
        1. 11.3.2.1. Function Template Overloading and Specialization Together
      3. 11.3.3. Friend Function Templates of Class Templates
    4. 11.4. Advanced Templates
      1. 11.4.1. More about Template Parameters
        1. 11.4.1.1. More about Template Type Parameters
          1. 11.4.1.1.1. Default Values for Template Type Parameters
        2. 11.4.1.2. Introducing Template Template Parameters
        3. 11.4.1.3. More about Nontype Template Parameters
          1. 11.4.1.3.1. Reference and Pointer Nontype Template Parameters
          2. 11.4.1.3.2. Using Zero-Initialization of Template Types
      2. 11.4.2. Template Class Partial Specialization
        1. 11.4.2.1. Another Form of Partial Specialization
      3. 11.4.3. Emulating Function Partial Specialization with Overloading
        1. 11.4.3.1. More on Deduction
      4. 11.4.4. Template Recursion
        1. 11.4.4.1. An N-Dimensional Grid: First Attempt
        2. 11.4.4.2. A Real N-Dimensional Grid
    5. 11.5. Summary
  17. 12. Understanding C++ Quirks and Oddities
    1. 12.1. References
      1. 12.1.1. Reference Variables
        1. 12.1.1.1. Modifying References
        2. 12.1.1.2. References to Pointers and Pointers to References
      2. 12.1.2. Reference Data Members
      3. 12.1.3. Reference Parameters
        1. 12.1.3.1. References from Pointers
        2. 12.1.3.2. Pass-by-Reference versus Pass-by-Value
      4. 12.1.4. Reference Return Values
      5. 12.1.5. Deciding between References and Pointers
    2. 12.2. Keyword Confusion
      1. 12.2.1. The const Keyword
        1. 12.2.1.1. const Variables
          1. 12.2.1.1.1. const Pointers
          2. 12.2.1.1.2. const References
        2. 12.2.1.2. const Methods
      2. 12.2.2. The static Keyword
        1. 12.2.2.1. Static Data Members and Methods
        2. 12.2.2.2. Static Linkage
          1. 12.2.2.2.1. The extern Keyword
        3. 12.2.2.3. static Variables in Functions
      3. 12.2.3. Order of Initialization of Nonlocal Variables
    3. 12.3. Types and Casts
      1. 12.3.1. typedefs
      2. 12.3.2. Casts
        1. 12.3.2.1. const_cast
        2. 12.3.2.2. static_cast
        3. 12.3.2.3. reinterpret_cast
        4. 12.3.2.4. dynamic_cast
        5. 12.3.2.5. Summary of Casts
    4. 12.4. Scope Resolution
    5. 12.5. Header Files
    6. 12.6. C Utilities
      1. 12.6.1. Variable-Length Argument Lists
        1. 12.6.1.1. Accessing the Arguments
        2. 12.6.1.2. Why You Shouldn't Use Variable-Length Argument Lists
      2. 12.6.2. Preprocessor Macros
    7. 12.7. Summary
  18. 13. Effective Memory Management
    1. 13.1. Working with Dynamic Memory
      1. 13.1.1. How to Picture Memory
      2. 13.1.2. Allocation and Deallocation
        1. 13.1.2.1. Using new and delete
        2. 13.1.2.2. What about My Good Friend malloc?
        3. 13.1.2.3. When Memory Allocation Fails
      3. 13.1.3. Arrays
        1. 13.1.3.1. Arrays of Basic Types
        2. 13.1.3.2. Arrays of Objects
        3. 13.1.3.3. Deleting Arrays
        4. 13.1.3.4. Multidimensional Arrays
          1. 13.1.3.4.1. Multidimensional Stack Arrays
          2. 13.1.3.4.2. Multidimensional Heap Arrays
      4. 13.1.4. Working with Pointers
        1. 13.1.4.1. A Mental Model for Pointers
        2. 13.1.4.2. Casting with Pointers
        3. 13.1.4.3. const with Pointers
    2. 13.2. Array-Pointer Duality
      1. 13.2.1. Arrays Are Pointers!
      2. 13.2.2. Not All Pointers Are Arrays!
    3. 13.3. Dynamic Strings
      1. 13.3.1. C-Style Strings
      2. 13.3.2. String Literals
      3. 13.3.3. The C++ string Class
        1. 13.3.3.1. What Was Wrong with C-Style Strings?
        2. 13.3.3.2. Using the string Class
    4. 13.4. Low-Level Memory Operations
      1. 13.4.1. Pointer Arithmetic
      2. 13.4.2. Custom Memory Management
      3. 13.4.3. Garbage Collection
      4. 13.4.4. Object Pools
      5. 13.4.5. Function Pointers
    5. 13.5. Common Memory Pitfalls
      1. 13.5.1. Underallocating Strings
      2. 13.5.2. Memory Leaks
        1. 13.5.2.1. Finding and Fixing Memory Leaks
        2. 13.5.2.2. Smart Pointers
      3. 13.5.3. Double-Deleting and Invalid Pointers
      4. 13.5.4. Accessing Out-of-Bounds Memory
    6. 13.6. Summary
  19. 14. Demystifying C++ I/O
    1. 14.1. Using Streams
      1. 14.1.1. What Is a Stream, Anyway?
      2. 14.1.2. Stream Sources and Destinations
      3. 14.1.3. Output with Streams
        1. 14.1.3.1. Output Basics
        2. 14.1.3.2. Methods of Output Streams
          1. 14.1.3.2.1. put() and write()
          2. 14.1.3.2.2. flush()
        3. 14.1.3.3. Handling Output Errors
        4. 14.1.3.4. Output Manipulators
      4. 14.1.4. Input with Streams
        1. 14.1.4.1. Input Basics
        2. 14.1.4.2. Input Methods
          1. 14.1.4.2.1. get()
          2. 14.1.4.2.2. unget()
          3. 14.1.4.2.3. putback()
          4. 14.1.4.2.4. peek ()
          5. 14.1.4.2.5. getline()
        3. 14.1.4.3. Handling Input Errors
        4. 14.1.4.4. Input Manipulators
      5. 14.1.5. Input and Output with Objects
    2. 14.2. String Streams
    3. 14.3. File Streams
      1. 14.3.1. Jumping around with seek() and tell()
      2. 14.3.2. Linking Streams Together
    4. 14.4. Bidirectional I/O
    5. 14.5. Internationalization
      1. 14.5.1. Wide Characters
      2. 14.5.2. Non-Western Character Sets
      3. 14.5.3. Locales and Facets
        1. 14.5.3.1. Using Locales
        2. 14.5.3.2. Using Facets
    6. 14.6. Summary
  20. 15. Handling Errors
    1. 15.1. Errors and Exceptions
      1. 15.1.1. What Are Exceptions, Anyway?
      2. 15.1.2. Why Exceptions in C++ Are a Good Thing
      3. 15.1.3. Why Exceptions in C++ Are a Bad Thing
      4. 15.1.4. Our Recommendation
    2. 15.2. Exception Mechanics
      1. 15.2.1. Throwing and Catching Exceptions
      2. 15.2.2. Exception Types
        1. 15.2.2.1. Catching Exception Objects by Const and Reference
      3. 15.2.3. Throwing and Catching Multiple Exceptions
        1. 15.2.3.1. Matching and Const
        2. 15.2.3.2. Matching Any Exception
      4. 15.2.4. Uncaught Exceptions
      5. 15.2.5. Throw Lists
        1. 15.2.5.1. Unexpected Exceptions
        2. 15.2.5.2. Changing the Throw List in Overridden Methods
        3. 15.2.5.3. Are Throw Lists Useful?
    3. 15.3. Exceptions and Polymorphism
      1. 15.3.1. The Standard Exception Hierarchy
      2. 15.3.2. Catching Exceptions in a Class Hierarchy
      3. 15.3.3. Writing Your Own Exception Classes
    4. 15.4. Stack Unwinding and Cleanup
      1. 15.4.1. Catch, Cleanup, and Rethrow
      2. 15.4.2. Use Smart Pointers
    5. 15.5. Common Error-Handling Issues
      1. 15.5.1. Memory Allocation Errors
        1. 15.5.1.1. Nothrow new
        2. 15.5.1.2. Customizing Memory Allocation Failure Behavior
      2. 15.5.2. Errors in Constructors
      3. 15.5.3. Errors in Destructors
    6. 15.6. Putting It All Together
    7. 15.7. Summary
  21. 16. Overloading C++ Operators
    1. 16.1. Overview of Operator Overloading
      1. 16.1.1. Why Overload Operators?
      2. 16.1.2. Limitations to Operator Overloading
      3. 16.1.3. Choices in Operator Overloading
        1. 16.1.3.1. Method or Global Function
        2. 16.1.3.2. Choosing Argument Types
        3. 16.1.3.3. Choosing Return Types
        4. 16.1.3.4. Choosing Behavior
      4. 16.1.4. Operators You Shouldn't Overload
      5. 16.1.5. Summary of Overloadable Operators
    2. 16.2. Overloading the Arithmetic Operators
      1. 16.2.1. Overloading Unary Minus and Unary Plus
      2. 16.2.2. Overloading Increment and Decrement
    3. 16.3. Overloading the Bitwise and Binary Logical Operators
    4. 16.4. Overloading the Insertion and Extraction Operators
    5. 16.5. Overloading the Subscripting Operator
      1. 16.5.1. Providing Read-Only Access with operator[]
      2. 16.5.2. Non-Integral Array Indices
    6. 16.6. Overloading the Function Call Operator
    7. 16.7. Overloading the Dereferencing Operators
      1. 16.7.1. Implementing operator*
      2. 16.7.2. Implementing Operator->
      3. 16.7.3. What in the World Is operator->* ?
    8. 16.8. Writing Conversion Operators
      1. 16.8.1. Ambiguity Problems with Conversion Operators
      2. 16.8.2. Conversions for Boolean Expressions
    9. 16.9. Overloading the Memory Allocation and Deallocation Operators
      1. 16.9.1. How new and delete Really Work
        1. 16.9.1.1. The New Expression and operator new
        2. 16.9.1.2. The Delete Expression and operator delete
      2. 16.9.2. Overloading operator new and operator delete
      3. 16.9.3. Overloading operator new and operator delete with Extra Parameters
    10. 16.10. Summary
  22. 17. Writing Efficient C++
    1. 17.1. Overview of Performance and Efficiency
      1. 17.1.1. Two Approaches to Efficiency
      2. 17.1.2. Two Kinds of Programs
      3. 17.1.3. Is C++ an Inefficient Language?
    2. 17.2. Language-Level Efficiency
      1. 17.2.1. Handle Objects Efficiently
        1. 17.2.1.1. Pass-by-Reference
        2. 17.2.1.2. Return by Reference
        3. 17.2.1.3. Catch Exceptions by Reference
        4. 17.2.1.4. Avoid Creating Temporary Objects
          1. 17.2.1.4.1. The Return-Value Optimization
      2. 17.2.2. Don't Overuse Costly Language Features
      3. 17.2.3. Use Inline Methods and Functions
    3. 17.3. Design-Level Efficiency
      1. 17.3.1. Cache as Much as Possible
        1. 17.3.1.1. Cache Invalidation
      2. 17.3.2. Use Object Pools
        1. 17.3.2.1. An Object Pool Implementation
        2. 17.3.2.2. Using the Object Pool
      3. 17.3.3. Use Thread Pools
    4. 17.4. Profiling
      1. 17.4.1. Profiling Example with gprof
        1. 17.4.1.1. First Design Attempt
        2. 17.4.1.2. Profile of the First Attempt
        3. 17.4.1.3. Second Attempt
        4. 17.4.1.4. Profile of the Second Attempt
    5. 17.5. Summary
  23. 18. Developing Cross-Platform and Cross-Language Applications
    1. 18.1. Cross-Platform Development
      1. 18.1.1. Architecture Issues
        1. 18.1.1.1. Binary Compatibility
        2. 18.1.1.2. Word and Type Sizes
        3. 18.1.1.3. Word Order
      2. 18.1.2. Implementation Issues
        1. 18.1.2.1. Compiler Quirks and Extensions
        2. 18.1.2.2. Library Implementations
      3. 18.1.3. Platform-Specific Features
    2. 18.2. Cross-Language Development
      1. 18.2.1. Mixing C and C++
      2. 18.2.2. Shifting Paradigms
      3. 18.2.3. Linking with C Code
      4. 18.2.4. Mixing Java and C++ with JNI
      5. 18.2.5. Mixing C++ with Perl and Shell Scripts
        1. 18.2.5.1. Scripting versus Programming
        2. 18.2.5.2. A Practical Example — Encrypting Passwords
      6. 18.2.6. Mixing C++ with Assembly Code
    3. 18.3. Summary
  24. 19. Becoming Adept at Testing
    1. 19.1. Quality Control
      1. 19.1.1. Whose Responsibility Is Testing?
      2. 19.1.2. The Life Cycle of a Bug
      3. 19.1.3. Bug-Tracking Tools
    2. 19.2. Unit Testing
      1. 19.2.1. Approaches to Unit Testing
      2. 19.2.2. The Unit Testing Process
        1. 19.2.2.1. Define the Granularity of Your Tests
        2. 19.2.2.2. Brainstorm the Individual Tests
        3. 19.2.2.3. Create Sample Data and Results
        4. 19.2.2.4. Write the Tests
        5. 19.2.2.5. Run the Tests
      3. 19.2.3. Unit Testing in Action
        1. 19.2.3.1. Introducing cppunit
        2. 19.2.3.2. Writing the First Test
        3. 19.2.3.3. Building a Suite of Tests
        4. 19.2.3.4. Adding the Real Tests
        5. 19.2.3.5. Basking in the Glorious Light of Unit Test Results
    3. 19.3. Higher-Level Testing
      1. 19.3.1. Integration Tests
        1. 19.3.1.1. Sample Integration Tests
          1. 19.3.1.1.1. An XML-Based File Serializer
          2. 19.3.1.1.2. Readers and Writers to a Shared Resource
          3. 19.3.1.1.3. Wrapper around a Third-Party Library
        2. 19.3.1.2. Methods of Integration Testing
      2. 19.3.2. System Tests
      3. 19.3.3. Regression Tests
    4. 19.4. Tips for Successful Testing
    5. 19.5. Summary
  25. 20. Conquering Debugging
    1. 20.1. The Fundamental Law of Debugging
    2. 20.2. Bug Taxonomies
    3. 20.3. Avoiding Bugs
    4. 20.4. Planning for Bugs
      1. 20.4.1. Error Logging
      2. 20.4.2. Debug Traces
        1. 20.4.2.1. Debug Mode
          1. 20.4.2.1.1. Compile-Time Debug Mode
          2. 20.4.2.1.2. Start-Time Debug Mode
          3. 20.4.2.1.3. Run-Time Debug Mode
        2. 20.4.2.2. Ring Buffers
          1. 20.4.2.2.1. Ring Buffer Interface
          2. 20.4.2.2.2. Ring Buffer Implementation
          3. 20.4.2.2.3. Using the Ring Buffer
          4. 20.4.2.2.4. Displaying the Ring Buffer Contents
      3. 20.4.3. Asserts
    5. 20.5. Debugging Techniques
      1. 20.5.1. Reproducing Bugs
      2. 20.5.2. Debugging Reproducible Bugs
      3. 20.5.3. Debugging Nonreproducible Bugs
      4. 20.5.4. Debugging Memory Problems
        1. 20.5.4.1. Categories of Memory Errors
          1. 20.5.4.1.1. Memory Freeing Errors
          2. 20.5.4.1.2. Memory Access Errors
        2. 20.5.4.2. Tips for Debugging Memory Errors
          1. 20.5.4.2.1. Object and Class-related Errors
          2. 20.5.4.2.2. General Memory Errors
      5. 20.5.5. Debugging Multithreaded Programs
      6. 20.5.6. Debugging Example: Article Citations
        1. 20.5.6.1. Buggy Implementation of an ArticleCitations Class
        2. 20.5.6.2. Testing the ArticleCitations class
          1. 20.5.6.2.1. cout Debugging
          2. 20.5.6.2.2. Using a Debugger
      7. 20.5.7. Lessons from the ArticleCitations Example
    6. 20.6. Summary
  26. 21. Delving into the STL: Containers and Iterators
    1. 21.1. Containers Overview
      1. 21.1.1. Requirements on Elements
      2. 21.1.2. Exceptions and Error Checking
      3. 21.1.3. Iterators
        1. 21.1.3.1. Common Iterator Typedefs and Methods
    2. 21.2. Sequential Containers
      1. 21.2.1. Vector
        1. 21.2.1.1. Vector Overview
          1. 21.2.1.1.1. Fixed-Length Vectors
          2. 21.2.1.1.2. Specifying an Initial Element Value
          3. 21.2.1.1.3. Other Vector Element Access Methods
        2. 21.2.1.2. Dynamic-Length Vectors
        3. 21.2.1.3. Vector Details
          1. 21.2.1.3.1. Constructors and Destructors
          2. 21.2.1.3.2. Copying and Assigning Vectors
          3. 21.2.1.3.3. Comparing Vectors
          4. 21.2.1.3.4. Vector Iterators
          5. 21.2.1.3.5. Accessing Fields of Object Elements
          6. 21.2.1.3.6. const_iterator
          7. 21.2.1.3.7. Iterator Safety
          8. 21.2.1.3.8. Other Iterator Operations
          9. 21.2.1.3.9. Iterators versus Indexing
          10. 21.2.1.3.10. Adding and Removing Elements
          11. 21.2.1.3.11. Algorithmic Complexity and Iterator Invalidation
          12. 21.2.1.3.12. The Vector Memory Allocation Scheme
          13. 21.2.1.3.13. Size and Capacity
          14. 21.2.1.3.14. Reserving Capacity
        4. 21.2.1.4. Vector Example: A Round-Robin Class
      2. 21.2.2. The vector<bool> Specialization
      3. 21.2.3. deque
      4. 21.2.4. list
        1. 21.2.4.1. Accessing Elements
        2. 21.2.4.2. Iterators
        3. 21.2.4.3. Adding and Removing Elements
        4. 21.2.4.4. List Size
        5. 21.2.4.5. Special List Operations
          1. 21.2.4.5.1. Splicing
          2. 21.2.4.5.2. More Efficient Versions of Algorithms
          3. 21.2.4.5.3. List Example: Determining Enrollment
    3. 21.3. Container Adapters
      1. 21.3.1. queue
        1. 21.3.1.1. Queue Operations
        2. 21.3.1.2. Queue Example: A Network Packet Buffer
      2. 21.3.2. priority_queue
        1. 21.3.2.1. Priority Queue Operations
        2. 21.3.2.2. Priority Queue Example: An Error Correlator
      3. 21.3.3. stack
        1. 21.3.3.1. Stack Operations
        2. 21.3.3.2. Stack Example: Revised Error Correlator
    4. 21.4. Associative Containers
      1. 21.4.1. The pair Utility Class
      2. 21.4.2. map
        1. 21.4.2.1. Constructing Maps
        2. 21.4.2.2. Inserting Elements
          1. 21.4.2.2.1. The insert() Method
          2. 21.4.2.2.2. operator[]
        3. 21.4.2.3. Map Iterators
        4. 21.4.2.4. Looking Up Elements
        5. 21.4.2.5. Removing Elements
        6. 21.4.2.6. Map Example: Bank Account
      3. 21.4.3. multimap
        1. 21.4.3.1. multimap Example: Buddy Lists
      4. 21.4.4. set
        1. 21.4.4.1. set Example: Access Control List
      5. 21.4.5. multiset
    5. 21.5. Other Containers
      1. 21.5.1. Arrays as STL Containers
      2. 21.5.2. Strings as STL Containers
      3. 21.5.3. Streams as STL Containers
      4. 21.5.4. bitset
        1. 21.5.4.1. bitset Basics
        2. 21.5.4.2. Bitwise Operators
        3. 21.5.4.3. bitset Example: Representing Cable Channels
    6. 21.6. Summary
  27. 22. Mastering STL Algorithms and Function Objects
    1. 22.1. Overview of Algorithms
      1. 22.1.1. The find() and find_if() Algorithms
      2. 22.1.2. The accumulate() Algorithms
    2. 22.2. Function Objects
      1. 22.2.1. Arithmetic Function Objects
      2. 22.2.2. Comparison Function Objects
      3. 22.2.3. Logical Function Objects
      4. 22.2.4. Function Object Adapters
        1. 22.2.4.1. Binders
        2. 22.2.4.2. Negators
        3. 22.2.4.3. Calling Member Functions
        4. 22.2.4.4. Adapting Real Functions
      5. 22.2.5. Writing Your Own Function Objects
    3. 22.3. Algorithm Details
      1. 22.3.1. Utility Algorithms
      2. 22.3.2. Nonmodifying Algorithms
        1. 22.3.2.1. Search Algorithms
        2. 22.3.2.2. Numerical Processing Algorithms
        3. 22.3.2.3. Comparison Algorithms
        4. 22.3.2.4. Operational Algorithms
      3. 22.3.3. Modifying Algorithms
        1. 22.3.3.1. Transform
        2. 22.3.3.2. Copy
        3. 22.3.3.3. Replace
        4. 22.3.3.4. Remove
        5. 22.3.3.5. Unique
        6. 22.3.3.6. Reverse
        7. 22.3.3.7. Other Modifying Algorithms
      4. 22.3.4. Sorting Algorithms
        1. 22.3.4.1. Basic Sorting and Merging
        2. 22.3.4.2. Heapsort
        3. 22.3.4.3. Other Sorting Routines
        4. 22.3.4.4. random_shuffle()
      5. 22.3.5. Set Algorithms
    4. 22.4. Algorithms and Function Objects Example: Auditing Voter Registrations
      1. 22.4.1. The Voter Registration Audit Problem Statement
      2. 22.4.2. The auditVoterRolls() Function
      3. 22.4.3. The getDuplicates() Function
      4. 22.4.4. The RemoveNames Functor
      5. 22.4.5. The NameInList Functor
      6. 22.4.6. Testing the auditVoterRolls() Function
    5. 22.5. Summary
  28. 23. Customizing and Extending the STL
    1. 23.1. Allocators
    2. 23.2. Iterator Adapters
      1. 23.2.1. Reverse Iterators
      2. 23.2.2. Stream Iterators
      3. 23.2.3. Insert Iterators
    3. 23.3. Extending the STL
      1. 23.3.1. Why Extend the STL?
      2. 23.3.2. Writing an STL Algorithm
        1. 23.3.2.1. find_all()
        2. 23.3.2.2. Iterator Traits
      3. 23.3.3. Writing an STL Container
        1. 23.3.3.1. A Basic Hashmap
          1. 23.3.3.1.1. The Hash Function
          2. 23.3.3.1.2. The Hashmap Interface
          3. 23.3.3.1.3. The Compare Template Argument
          4. 23.3.3.1.4. The Hash Template Argument
          5. 23.3.3.1.5. The typedefs
          6. 23.3.3.1.6. The Implementation
          7. 23.3.3.1.7. The Constructor
          8. 23.3.3.1.8. Destructor, Copy Constructor, and Assignment Operator
          9. 23.3.3.1.9. Element Lookup
          10. 23.3.3.1.10. Element Insert
          11. 23.3.3.1.11. Element Delete
          12. 23.3.3.1.12. Using the Basic Hashmap
        2. 23.3.3.2. Making the Hashmap an STL Container
          1. 23.3.3.2.1. Typedef Container Requirements
          2. 23.3.3.2.2. Method Container Requirements
          3. 23.3.3.2.3. Writing an Iterator
          4. 23.3.3.2.4. The HashIterator Class
          5. 23.3.3.2.5. The HashIterator Method Implementations
          6. 23.3.3.2.6. Const Iterators
          7. 23.3.3.2.7. Iterator Typedefs and Access Methods
          8. 23.3.3.2.8. Using the HashIterator
        3. 23.3.3.3. Note on Allocators
        4. 23.3.3.4. Note on Reversible Containers
        5. 23.3.3.5. Making the Hashmap an Associative Container
          1. 23.3.3.5.1. Associative Container Typedef Requirements
          2. 23.3.3.5.2. Associative Container Method Requirements
          3. 23.3.3.5.3. hashmap Constructors
          4. 23.3.3.5.4. hashmap Insertion Operations
          5. 23.3.3.5.5. hashmap Erase Operations
          6. 23.3.3.5.6. hashmap Accessor Operations
        6. 23.3.3.6. Note on Sequential Containers
    4. 23.4. Summary
  29. 24. Exploring Distributed Objects
    1. 24.1. The Appeal of Distributed Computing
      1. 24.1.1. Distribution for Scalability
      2. 24.1.2. Distribution for Reliability
      3. 24.1.3. Distribution for Centrality
      4. 24.1.4. Distributed Content
      5. 24.1.5. Distributed versus Networked
    2. 24.2. Distributed Objects
      1. 24.2.1. Serialization and Marshalling
        1. 24.2.1.1. Serialization in Action
      2. 24.2.2. Remote Procedure Calls
    3. 24.3. CORBA
      1. 24.3.1. Interface Definition Language
        1. 24.3.1.1. Writing the Interface
        2. 24.3.1.2. Generating Stubs and Skeletons
          1. 24.3.1.2.1. Stubs
          2. 24.3.1.2.2. Skeletons
      2. 24.3.2. Implementing the Class
      3. 24.3.3. Using the Objects
        1. 24.3.3.1. The Server Process
        2. 24.3.3.2. The Client Process
    4. 24.4. XML
      1. 24.4.1. A Crash Course in XML
        1. 24.4.1.1. What Is XML?
        2. 24.4.1.2. XML Structure and Terminology
      2. 24.4.2. XML as a Distributed Object Technology
      3. 24.4.3. Generating and Parsing XML in C++
        1. 24.4.3.1. Generating XML
          1. 24.4.3.1.1. An XML Output Class
        2. 24.4.3.2. Parsing XML
          1. 24.4.3.2.1. The Xerces XML Library
          2. 24.4.3.2.2. Using Xerces
      4. 24.4.4. XML Validation
        1. 24.4.4.1. DTD (Document Type Definition)
        2. 24.4.4.2. XML Schema
      5. 24.4.5. Building a Distributed Object with XML
        1. 24.4.5.1. The XMLSerializable Mix-in Class
        2. 24.4.5.2. Implementing XML Serialization
        3. 24.4.5.3. Using the Distributed Object
      6. 24.4.6. SOAP (Simple Object Access Protocol)
        1. 24.4.6.1. An Introduction to SOAP
    5. 24.5. Summary
  30. 25. Incorporating Techniques and Frameworks
    1. 25.1. "I Can Never Remember How to . . ."
      1. 25.1.1. ... Write a Class
      2. 25.1.2. ... Subclass an Existing Class
      3. 25.1.3. ... Throw and Catch Exceptions
      4. 25.1.4. ... Read from a File
      5. 25.1.5. ... Write to a File
      6. 25.1.6. ... Write a Template Class
    2. 25.2. There Must Be a Better Way
      1. 25.2.1. Smart Pointers with Reference Counting
        1. 25.2.1.1. The Need for Reference Counting
        2. 25.2.1.2. The SuperSmartPointer
        3. 25.2.1.3. Unit Testing the SuperSmartPointers
        4. 25.2.1.4. Enhancing This Implementation
      2. 25.2.2. Double Dispatcha
        1. 25.2.2.1. Attempt #1: Brute Force
        2. 25.2.2.2. Attempt #2: Single Polyamorphism with Overloading
        3. 25.2.2.3. Attempt #3: Double Dispatch
      3. 25.2.3. Mix-In Classes
        1. 25.2.3.1. Designing a Mix-In Class
        2. 25.2.3.2. Implementing a Mix-In Class
        3. 25.2.3.3. Using a Mix-In Class
    3. 25.3. Object-Oriented Frameworks
      1. 25.3.1. Working with Frameworks
      2. 25.3.2. The Model-View-Controller Paradigm
    4. 25.4. Summary
  31. 26. Applying Design Patterns
    1. 26.1. The Singleton Pattern
      1. 26.1.1. Example: A Logging Mechanism
      2. 26.1.2. Implementation of a Singleton
        1. 26.1.2.1. Static Class Singleton
        2. 26.1.2.2. Access-Controlled Singleton
      3. 26.1.3. Using a Singleton
    2. 26.2. The Factory Pattern
      1. 26.2.1. Example: A Car Factory Simulation
      2. 26.2.2. Implementation of a Factory
      3. 26.2.3. Using a Factory
      4. 26.2.4. Other Uses of Factories
    3. 26.3. The Proxy Pattern
      1. 26.3.1. Example: Hiding Network Connectivity Issues
      2. 26.3.2. Implementation of a Proxy
      3. 26.3.3. Using a Proxy
    4. 26.4. The Adapter Pattern
      1. 26.4.1. Example: Adapting an XML Library
        1. 26.4.1.1. Implementation of an Adapter
      2. 26.4.2. Using an Adapter
    5. 26.5. The Decorator Pattern
      1. 26.5.1. Example: Defining Styles in Web Pages
      2. 26.5.2. Implementation of a Decorator
      3. 26.5.3. Using a Decorator
    6. 26.6. The Chain of Responsibility Pattern
      1. 26.6.1. Example: Event Handling
      2. 26.6.2. Implementation of a Chain of Responsibility
      3. 26.6.3. Using a Chain of Responsibility
    7. 26.7. The Observer Pattern
      1. 26.7.1. Example: Event Handling
        1. 26.7.1.1. Implementation of an Observer
      2. 26.7.2. Using an Observer
    8. 26.8. Summary
  32. A. C++ Interviews
    1. A.1. Chapter 1: A Crash Course in C++
      1. A.1.1. Things to Remember
      2. A.1.2. Types of Questions
    2. A.2. Chapter 2: Designing Professional C++ Programs
      1. A.2.1. Things to Remember
      2. A.2.2. Types of Questions
    3. A.3. Chapter 3: Designing with Objects
      1. A.3.1. Things to Remember
      2. A.3.2. Types of Questions
    4. A.4. Chapter 4: Designing with Libraries and Patterns
      1. A.4.1. Things to Remember
      2. A.4.2. Types of Questions
    5. A.5. Chapter 5: Designing for Reuse
      1. A.5.1. Things to Remember
      2. A.5.2. Types of Questions
    6. A.6. Chapter 6: Maximizing Software Engineering Methods
      1. A.6.1. Things to Remember
      2. A.6.2. Types of Questions
    7. A.7. Chapter 7: Coding with Style
      1. A.7.1. Things to Remember
      2. A.7.2. Types of Questions
    8. A.8. Chapters 8 and 9: Classes and Objects
      1. A.8.1. Things to Remember
      2. A.8.2. Types of Questions
    9. A.9. Chapter 10: Discovering Inheritance Techniques
      1. A.9.1. Things to Remember
      2. A.9.2. Types of Questions
    10. A.10. Chapter 11: Writing Generic Code with Templates
      1. A.10.1. Things to Remember
      2. A.10.2. Types of Questions
    11. A.11. Chapter 12: Understanding C++ Quirks and Oddities
      1. A.11.1. Things to Remember
      2. A.11.2. Types of Questions
    12. A.12. Chapter 13: Effective Memory Management
      1. A.12.1. Things to Remember
      2. A.12.2. Types of Questions
    13. A.13. Chapter 14: Demystifying C++ I/O
      1. A.13.1. Things to Remember
      2. A.13.2. Types of Questions
    14. A.14. Chapter 15: Handling Errors
      1. A.14.1. Things to Remember
      2. A.14.2. Types of Questions
    15. A.15. Chapter 16: Overloading C++ Operators
      1. A.15.1. Things to Remember
      2. A.15.2. Types of Questions
    16. A.16. Chapter 17: Writing Efficient C++
      1. A.16.1. Things to Remember
      2. A.16.2. Types of Questions
    17. A.17. Chapter 18: Developing Cross-Platform and Cross-Language Applications
      1. A.17.1. Things to Remember
      2. A.17.2. Types of Questions
    18. A.18. Chapter 19: Becoming Adept at Testing
      1. A.18.1. Things to Remember
      2. A.18.2. Types of Questions
    19. A.19. Chapter 20: Conquering Debugging
      1. A.19.1. Things to Remember
      2. A.19.2. Types of Questions
    20. A.20. Chapters 21, 22, and 23: The Standard Template Library
      1. A.20.1. Things to Remember
      2. A.20.2. Types of Questions
    21. A.21. Chapter 24: Exploring Distributed Objects
      1. A.21.1. Things to Remember
      2. A.21.2. Types of Questions
    22. A.22. Chapter 25: Incorporating Techniques and Frameworks
    23. A.23. Chapter 26: Applying Design Patterns
      1. A.23.1. Things to Remember
      2. A.23.2. Types of Questions
  33. B. Annotated Bibliography
    1. B.1. C++
      1. B.1.1. Beginning C++
      2. B.1.2. General C++
      3. B.1.3. I/O Streams
      4. B.1.4. The C++ Standard Library
      5. B.1.5. C++ Templates
    2. B.2. C
    3. B.3. Integrating C++ and Other Languages
    4. B.4. Algorithms and Data Structures
    5. B.5. Open-Source Software
    6. B.6. Software-Engineering Methodology
    7. B.7. Programming Style
    8. B.8. Computer Architecture
    9. B.9. Efficiency
    10. B.10. Testing
    11. B.11. Debugging
    12. B.12. Distributed Objects
      1. B.12.1. CORBA
      2. B.12.2. XML and SOAP
    13. B.13. Design Patterns
  34. 27. Standard Library Header Files
    1. BC1.1. The C Standard Library
    2. BC1.2. Containers
    3. BC1.3. Algorithms, Iterators, and Allocators
    4. BC1.4. General Utilities
    5. BC1.5. Mathematical Utilities
    6. BC1.6. Exceptions
    7. BC1.7. I/O Streams
  35. 28. Standard Library Reference
    1. BC2.1. Containers
      1. BC2.1.1. Common Typedefs
      2. BC2.1.2. Common Iterator Methods
      3. BC2.1.3. Common Comparison Operators
      4. BC2.1.4. Other Common Functions and Methods
      5. BC2.1.5. Note on Running Time
      6. BC2.1.6. Sequential Containers
      7. BC2.1.7. vector
        1. BC2.1.7.1. Iterator
        2. BC2.1.7.2. Template Definition
        3. BC2.1.7.3. Constructors, Destructors, and Assignment Methods
        4. BC2.1.7.4. Adding and Deleting Elements
        5. BC2.1.7.5. Accessing Elements
        6. BC2.1.7.6. Retrieving and Setting Size and Capacity
        7. BC2.1.7.7. The vector<bool> Specialization
        8. BC2.1.7.8. reference Class
        9. BC2.1.7.9. Bit Methods
      8. BC2.1.8. deque
        1. BC2.1.8.1. Iterator
        2. BC2.1.8.2. Template Definition
        3. BC2.1.8.3. Constructors, Destructors, and Assignment Methods
        4. BC2.1.8.4. Adding and Deleting Elements
        5. BC2.1.8.5. Accessing Elements
        6. BC2.1.8.6. Retrieving and Setting Size
      9. BC2.1.9. list
        1. BC2.1.9.1. Iterator
        2. BC2.1.9.2. Template Definition
        3. BC2.1.9.3. Constructors, Destructors, and Assignment Methods
        4. BC2.1.9.4. Adding and Deleting Elements
        5. BC2.1.9.5. Accessing Elements
        6. BC2.1.9.6. Retrieving and Setting Size
        7. BC2.1.9.7. List Operations
      10. BC2.1.10. Container Adapters
      11. BC2.1.11. stack
        1. BC2.1.11.1. Template Definition
        2. BC2.1.11.2. Constructors, Destructors, and Assignment Methods
        3. BC2.1.11.3. Adding and Deleting Elements
        4. BC2.1.11.4. Accessing Elements
        5. BC2.1.11.5. Retrieving Size
      12. BC2.1.12. queue
        1. BC2.1.12.1. Template Definition
        2. BC2.1.12.2. Constructors, Destructors, and Assignment Methods
        3. BC2.1.12.3. Adding and Deleting Elements
        4. BC2.1.12.4. Accessing Elements
        5. BC2.1.12.5. Retrieving Size
      13. BC2.1.13. priority_queue
        1. BC2.1.13.1. Template Definition
        2. BC2.1.13.2. Constructors, Destructors, and Assignment Methods
        3. BC2.1.13.3. Adding and Deleting Elements
        4. BC2.1.13.4. Accessing Elements
        5. BC2.1.13.5. Retrieving Size
      14. BC2.1.14. Associative Containers
      15. BC2.1.15. Associative Container Typedefs
      16. BC2.1.16. map and multimap
        1. BC2.1.16.1. Iterators
        2. BC2.1.16.2. Template Definition
        3. BC2.1.16.3. Constructors, Destructors, and Assignment Methods
        4. BC2.1.16.4. Adding and Deleting Elements
        5. BC2.1.16.5. Accessing Elements
        6. BC2.1.16.6. Retrieving Size and Comparison Objects
      17. BC2.1.17. set and multiset
        1. BC2.1.17.1. Iterators
        2. BC2.1.17.2. Template Definition
        3. BC2.1.17.3. Constructors, Destructors, and Assignment Methods
        4. BC2.1.17.4. Adding and Deleting Elements
        5. BC2.1.17.5. Accessing Elements
        6. BC2.1.17.6. Retrieving Size and Comparison Objects
      18. BC2.1.18. bitset
      19. BC2.1.19. Template Definition
        1. BC2.1.19.1. Constructors
        2. BC2.1.19.2. Bit Manipulation Methods
        3. BC2.1.19.3. Overloaded Bitwise Operators
        4. BC2.1.19.4. Stream Operators
        5. BC2.1.19.5. Obtaining Information about Bits in the Bitset
      20. BC2.1.20. string
      21. BC2.1.21. Iterator
      22. BC2.1.22. Note on Exceptions
      23. BC2.1.23. Note on npos
      24. BC2.1.24. Constructors, Destructors, and Assignment Methods
      25. BC2.1.25. Adding and Deleting Characters
      26. BC2.1.26. Accessing Characters
      27. BC2.1.27. Obtaining Characters
      28. BC2.1.28. Retrieving and Setting Size and Capacity
        1. BC2.1.28.1. Searching
        2. BC2.1.28.2. Comparisons
        3. BC2.1.28.3. Concatenating strings
        4. BC2.1.28.4. Streaming strings
    2. BC2.2. Algorithms
      1. BC2.2.1. Utility Algorithms
      2. BC2.2.2. Nonmodifying Algorithms
        1. BC2.2.2.1. Search Algorithms
        2. BC2.2.2.2. Numerical Processing Algorithms
        3. BC2.2.2.3. Comparison Algorithms
        4. BC2.2.2.4. Operational Algorithms
      3. BC2.2.3. Modifying Algorithms
      4. BC2.2.4. Sorting Algorithms
      5. BC2.2.5. Set Algorithms
    3. BC2.3. Streams
      1. BC2.3.1. Predefined iostream Objects
      2. BC2.3.2. Predefined stream Manipulators
      3. BC2.3.3. ios
        1. BC2.3.3.1. Stream Status Methods
      4. BC2.3.4. istream
        1. BC2.3.4.1. Manipulators
        2. BC2.3.4.2. Formatted Input
        3. BC2.3.4.3. Unformatted Input
        4. BC2.3.4.4. Input Stream Navigation
      5. BC2.3.5. ostream
        1. BC2.3.5.1. Manipulators
        2. BC2.3.5.2. Formatted Output
        3. BC2.3.5.3. Unformatted Output
        4. BC2.3.5.4. Output Stream Navigation

Product information

  • Title: Professional C++
  • Author(s): Nicholas A. Solter, Scott J. Kleper
  • Release date: January 2005
  • Publisher(s): Wrox
  • ISBN: 9780764574849