The C++ Programming Language, Special Edition

Book description

More than three-quarters of a million programmers have benefited from this book in all of its editions

Written by Bjarne Stroustrup, the creator of C++, this is the world's most trusted and widely read book on C++.

For this special hardcover edition, two new appendixes on locales and standard library exception safety (also available at www.research.att.com/~bs/) have been added. The result is complete, authoritative coverage of the C++ language, its standard library, and key design techniques. Based on the ANSI/ISO C++ standard, The C++ Programming Language provides current and comprehensive coverage of all C++ language features and standard library components.

For example:

  • abstract classes as interfaces

  • class hierarchies for object-oriented programming

  • templates as the basis for type-safe generic software

  • exceptions for regular error handling

  • namespaces for modularity in large-scale software

  • run-time type identification for loosely coupled systems

  • the C subset of C++ for C compatibility and system-level work

  • standard containers and algorithms

  • standard strings, I/O streams, and numerics

  • C compatibility, internationalization, and exception safety

  • Bjarne Stroustrup makes C++ even more accessible to those new to the language, while adding advanced information and techniques that even expert C++ programmers will find invaluable.



    Table of contents

    1. Copyright
    2. Preface
      1. Acknowledgments
    3. Preface to the Second Edition
      1. Acknowledgments
    4. Preface to the First Edition
      1. Acknowledgments
    5. Introduction
      1. 1. Notes to the Reader
        1. 1.1. The Structure of This Book
          1. 1.1.1. Examples and References
          2. 1.1.2. Exercises
          3. 1.1.3. Implementation Note
        2. 1.2. Learning C++
        3. 1.3. The Design of C++
          1. 1.3.1. Efficiency and Structure
          2. 1.3.2. Philosophical Note
        4. 1.4. Historical Note
        5. 1.5. Use of C++
        6. 1.6. C and C++
          1. 1.6.1. Suggestions for C Programmers
          2. 1.6.2. Suggestions for C++ Programmers
        7. 1.7. Thinking about Programming in C++
        8. 1.8. Advice
          1. 1.8.1. References
      2. 2. A Tour of C++
        1. 2.1. What is C++?
        2. 2.2. Programming Paradigms
        3. 2.3. Procedural Programming
          1. 2.3.1. Variables and Arithmetic
          2. 2.3.2. Tests and Loops
          3. 2.3.3. Pointers and Arrays
        4. 2.4. Modular Programming
          1. 2.4.1. Separate Compilation
          2. 2.4.2. Exception Handling
        5. 2.5. Data Abstraction
          1. 2.5.1. Modules Defining Types
          2. 2.5.2. User-Defined Types
          3. 2.5.3. Concrete Types
          4. 2.5.4. Abstract Types
          5. 2.5.5. Virtual Functions
        6. 2.6. Object-Oriented Programming
          1. 2.6.1. Problems with Concrete Types
          2. 2.6.2. Class Hierarchies
        7. 2.7. Generic Programming
          1. 2.7.1. Containers
          2. 2.7.2. Generic Algorithms
        8. 2.8. Postscript
        9. 2.9. Advice
      3. 3. A Tour of the Standard Library
        1. 3.1. Introduction
        2. 3.2. Hello, world!
        3. 3.3. The Standard Library Namespace
        4. 3.4. Output
        5. 3.5. Strings
          1. 3.5.1. C-Style Strings
        6. 3.6. Input
        7. 3.7. Containers
          1. 3.7.1. Vector
          2. 3.7.2. Range Checking
          3. 3.7.3. List
          4. 3.7.4. Map
          5. 3.7.5. Standard Containers
        8. 3.8. Algorithms
          1. 3.8.1. Use of Iterators
          2. 3.8.2. Iterator Types
          3. 3.8.3. Iterators and I/O
          4. 3.8.4. Traversals and Predicates
          5. 3.8.5. Algorithms Using Member Functions
          6. 3.8.6. Standard Library Algorithms
        9. 3.9. Math
          1. 3.9.1. Complex Numbers
          2. 3.9.2. Vector Arithmetic
          3. 3.9.3. Basic Numeric Support
        10. 3.10. Standard Library Facilities
        11. 3.11. Advice
    6. I. Basic Facilities
      1. 4. Types and Declarations
        1. 4.1. Types
          1. 4.1.1. Fundamental Types
        2. 4.2. Booleans
        3. 4.3. Character Types
          1. 4.3.1. Character Literals
        4. 4.4. Integer Types
          1. 4.4.1. Integer Literals
        5. 4.5. Floating-Point Types
          1. 4.5.1. Floating-Point Literals
        6. 4.6. Sizes
        7. 4.7. Void
        8. 4.8. Enumerations
        9. 4.9. Declarations
          1. 4.9.1. The Structure of a Declaration
          2. 4.9.2. Declaring Multiple Names
          3. 4.9.3. Names
          4. 4.9.4. Scope
          5. 4.9.5. Initialization
          6. 4.9.6. Objects and Lvalues
          7. 4.9.7. Typedef
        10. 4.10. Advice
        11. 4.11. Exercises
      2. 5. Pointers, Arrays, and Structures
        1. 5.1. Pointers
          1. 5.1.1. Zero
        2. 5.2. Arrays
          1. 5.2.1. Array Initializers
          2. 5.2.2. String Literals
        3. 5.3. Pointers into Arrays
          1. 5.3.1. Navigating Arrays
        4. 5.4. Constants
          1. 5.4.1. Pointers and Constants
        5. 5.5. References
        6. 5.6. Pointer to Void
        7. 5.7. Structures
          1. 5.7.1. Type Equivalence
        8. 5.8. Advice
        9. 5.9. Exercises
      3. 6. Expressions and Statements
        1. 6.1. A Desk Calculator
          1. 6.1.1. The Parser
          2. 6.1.2. The Input Function
          3. 6.1.3. Low-level Input
          4. 6.1.4. Error Handling
          5. 6.1.5. The Driver
          6. 6.1.6. Headers
          7. 6.1.7. Command-Line Arguments
          8. 6.1.8. A Note on Style
        2. 6.2. Operator Summary
          1. 6.2.1. Results
          2. 6.2.2. Evaluation Order
          3. 6.2.3. Operator Precedence
          4. 6.2.4. Bitwise Logical Operators
          5. 6.2.5. Increment and Decrement
          6. 6.2.6. Free Store
            1. 6.2.6.1. Arrays
            2. 6.2.6.2. Memory Exhaustion
          7. 6.2.7. Explicit Type Conversion
          8. 6.2.8. Constructors
        3. 6.3. Statement Summary
          1. 6.3.1. Declarations as Statements
          2. 6.3.2. Selection Statements
            1. 6.3.2.1. Declarations in Conditions
          3. 6.3.3. Iteration Statements
            1. 6.3.3.1. Declarations in For-Statements
          4. 6.3.4. Goto
        4. 6.4. Comments and Indentation
        5. 6.5. Advice
        6. 6.6. Exercises
      4. 7. Functions
        1. 7.1. Function Declarations
          1. 7.1.1. Function Definitions
          2. 7.1.2. Static Variables
        2. 7.2. Argument Passing
          1. 7.2.1. Array Arguments
        3. 7.3. Value Return
        4. 7.4. Overloaded Function Names
          1. 7.4.1. Overloading and Return Type
          2. 7.4.2. Overloading and Scopes
          3. 7.4.3. Manual Ambiguity Resolution
          4. 7.4.4. Resolution for Multiple Arguments
        5. 7.5. Default Arguments
        6. 7.6. Unspecified Number of Arguments
        7. 7.7. Pointer to Function
        8. 7.8. Macros
          1. 7.8.1. Conditional Compilation
        9. 7.9. Advice
        10. 7.10. Exercises
      5. 8. Namespaces and Exceptions
        1. 8.1. Modularization and Interfaces
        2. 8.2. Namespaces
          1. 8.2.1. Qualified Names
          2. 8.2.2. Using Declarations
          3. 8.2.3. Using Directives
          4. 8.2.4. Multiple Interfaces
            1. 8.2.4.1. Interface Design Alternatives
          5. 8.2.5. Avoiding Name Clashes
            1. 8.2.5.1. Unnamed Namespaces
          6. 8.2.6. Name Lookup
          7. 8.2.7. Namespace Aliases
          8. 8.2.8. Namespace Composition
            1. 8.2.8.1. Selection
            2. 8.2.8.2. Composition and Selection
          9. 8.2.9. Namespaces and Old Code
            1. 8.2.9.1. Namespaces and C
            2. 8.2.9.2. Namespaces and Overloading
            3. 8.2.9.3. Namespaces Are Open
        3. 8.3. Exceptions
          1. 8.3.1. Throw and Catch
          2. 8.3.2. Discrimination of Exceptions
          3. 8.3.3. Exceptions in the Calculator
            1. 8.3.3.1. Alternative Error-Handling Strategies
        4. 8.4. Advice
        5. 8.5. Exercises
      6. 9. Source Files and Programs
        1. 9.1. Separate Compilation
        2. 9.2. Linkage
          1. 9.2.1. Header Files
          2. 9.2.2. Standard Library Headers
          3. 9.2.3. The One-Definition Rule
          4. 9.2.4. Linkage to Non-C++ Code
          5. 9.2.5. Linkage and Pointers to Functions
        3. 9.3. Using Header Files
          1. 9.3.1. Single Header File
          2. 9.3.2. Multiple Header Files
            1. 9.3.2.1. Other Calculator Modules
            2. 9.3.2.2. Use of Headers
          3. 9.3.3. Include Guards
        4. 9.4. Programs
          1. 9.4.1. Initialization of Nonlocal Variables
            1. 9.4.1.1. Program Termination
        5. 9.5. Advice
        6. 9.6. Exercises
    7. II. Abstraction Mechanisms
      1. 10. Classes
        1. 10.1. Introduction
        2. 10.2. Classes
          1. 10.2.1. Member Functions
          2. 10.2.2. Access Control
          3. 10.2.3. Constructors
          4. 10.2.4. Static Members
          5. 10.2.5. Copying Class Objects
          6. 10.2.6. Constant Member Functions
          7. 10.2.7. Self-Reference
            1. 10.2.7.1. Physical and Logical Constness
            2. 10.2.7.2. Mutable
          8. 10.2.8. Structures and Classes
          9. 10.2.9. In-Class Function Definitions
        3. 10.3. Efficient User-Defined Types
          1. 10.3.1. Member Functions
          2. 10.3.2. Helper Functions
          3. 10.3.3. Overloaded Operators
          4. 10.3.4. The Significance of Concrete Classes
        4. 10.4. Objects
          1. 10.4.1. Destructors
          2. 10.4.2. Default Constructors
          3. 10.4.3. Construction and Destruction
          4. 10.4.4. Local Variables
            1. 10.4.4.1. Copying Objects
          5. 10.4.5. Free Store
          6. 10.4.6. Class Objects as Members
            1. 10.4.6.1. Necessary Member Initialization
            2. 10.4.6.2. Member Constants
            3. 10.4.6.3. Copying Members
          7. 10.4.7. Arrays
          8. 10.4.8. Local Static Store
          9. 10.4.9. Nonlocal Store
          10. 10.4.10. Temporary Objects
          11. 10.4.11. Placement of Objects
          12. 10.4.12. Unions
        5. 10.5. Advice
        6. 10.6. Exercises
      2. 11. Operator Overloading
        1. 11.1. Introduction
        2. 11.2. Operator Functions
          1. 11.2.1. Binary and Unary Operators
          2. 11.2.2. Predefined Meanings for Operators
          3. 11.2.3. Operators and User-Defined Types
          4. 11.2.4. Operators in Namespaces
        3. 11.3. A Complex Number Type
          1. 11.3.1. Member and Nonmember Operators
          2. 11.3.2. Mixed-Mode Arithmetic
          3. 11.3.3. Initialization
          4. 11.3.4. Copying
          5. 11.3.5. Constructors and Conversions
          6. 11.3.6. Literals
          7. 11.3.7. Additional Member Functions
          8. 11.3.8. Helper Functions
        4. 11.4. Conversion Operators
          1. 11.4.1. Ambiguities
        5. 11.5. Friends
          1. 11.5.1. Finding Friends
          2. 11.5.2. Friends and Members
        6. 11.6. Large Objects
        7. 11.7. Essential Operators
          1. 11.7.1. Explicit Constructors
        8. 11.8. Subscripting
        9. 11.9. Function Call
        10. 11.10. Dereferencing
        11. 11.11. Increment and Decrement
        12. 11.12. A String Class
        13. 11.13. Advice
        14. 11.14. Exercises
      3. 12. Derived Classes
        1. 12.1. Introduction
        2. 12.2. Derived Classes
          1. 12.2.1. Member Functions
          2. 12.2.2. Constructors and Destructors
          3. 12.2.3. Copying
          4. 12.2.4. Class Hierarchies
          5. 12.2.5. Type Fields
          6. 12.2.6. Virtual Functions
        3. 12.3. Abstract Classes
        4. 12.4. Design of Class Hierarchies
          1. 12.4.1. A Traditional Class Hierarchy
            1. 12.4.1.1. Critique
          2. 12.4.2. Abstract Classes
          3. 12.4.3. Alternative Implementations
            1. 12.4.3.1. Critique
          4. 12.4.4. Localizing Object Creation
        5. 12.5. Class Hierarchies and Abstract Classes
        6. 12.6. Advice
        7. 12.7. Exercises
      4. 13. Templates
        1. 13.1. Introduction
        2. 13.2. A Simple String Template
          1. 13.2.1. Defining a Template
          2. 13.2.2. Template Instantiation
          3. 13.2.3. Template Parameters
          4. 13.2.4. Type Equivalence
          5. 13.2.5. Type Checking
        3. 13.3. Function Templates
          1. 13.3.1. Function Template Arguments
          2. 13.3.2. Function Template Overloading
        4. 13.4. Using Template Arguments to Specify Policy
          1. 13.4.1. Default Template Parameters
        5. 13.5. Specialization
          1. 13.5.1. Order of Specializations
          2. 13.5.2. Template Function Specialization
        6. 13.6. Derivation and Templates
          1. 13.6.1. Parameterization and Inheritance
          2. 13.6.2. Member Templates
          3. 13.6.3. Inheritance Relationships
            1. 13.6.3.1. Template Conversions
        7. 13.7. Source Code Organization
        8. 13.8. Advice
        9. 13.9. Exercises
      5. 14. Exception Handling
        1. 14.1. Error Handling
          1. 14.1.1. Alternative Views on Exceptions
        2. 14.2. Grouping of Exceptions
          1. 14.2.1. Derived Exceptions
          2. 14.2.2. Composite Exceptions
        3. 14.3. Catching Exceptions
          1. 14.3.1. Re-Throw
          2. 14.3.2. Catch Every Exception
            1. 14.3.2.1. Order of Handlers
        4. 14.4. Resource Management
          1. 14.4.1. Using Constructors and Destructors
          2. 14.4.2. Auto_ptr
          3. 14.4.3. Caveat
          4. 14.4.4. Exceptions and New
          5. 14.4.5. Resource Exhaustion
          6. 14.4.6. Exceptions in Constructors
            1. 14.4.6.1. Exceptions and Member Initialization
            2. 14.4.6.2. Exceptions and Copying
          7. 14.4.7. Exceptions in Destructors
        5. 14.5. Exceptions That Are Not Errors
        6. 14.6. Exception Specifications
          1. 14.6.1. Checking Exception Specifications
          2. 14.6.2. Unexpected Exceptions
          3. 14.6.3. Mapping Exceptions
            1. 14.6.3.1. User Mapping of Exceptions
            2. 14.6.3.2. Recovering the Type of an Exception
        7. 14.7. Uncaught Exceptions
        8. 14.8. Exceptions and Efficiency
        9. 14.9. Error-Handling Alternatives
        10. 14.10. Standard Exceptions
        11. 14.11. Advice
        12. 14.12. Exercises
      6. 15. Class Hierarchies
        1. 15.1. Introduction and Overview
        2. 15.2. Multiple Inheritance
          1. 15.2.1. Ambiguity Resolution
          2. 15.2.2. Inheritance and Using-Declarations
          3. 15.2.3. Replicated Base Classes
            1. 15.2.3.1. Overriding
          4. 15.2.4. Virtual Base Classes
            1. 15.2.4.1. Programming Virtual Bases
          5. 15.2.5. Using Multiple Inheritance
            1. 15.2.5.1. Overriding Virtual Base Functions
        3. 15.3. Access Control
          1. 15.3.1. Protected Members
            1. 15.3.1.1. Use of Protected Members
          2. 15.3.2. Access to Base Classes
            1. 15.3.2.1. Multiple Inheritance and Access Control
            2. 15.3.2.2. Using-Declarations and Access Control
        4. 15.4. Run-Time Type Information
          1. 15.4.1. Dynamic_cast
            1. 15.4.1.1. Dynamic_cast of References
          2. 15.4.2. Navigating Class Hierarchies
            1. 15.4.2.1. Static and Dynamic Casts
          3. 15.4.3. Class Object Construction and Destruction
          4. 15.4.4. Typeid and Extended Type Information
            1. 15.4.4.1. Extended Type Information
          5. 15.4.5. Uses and Misuses of RTTI
        5. 15.5. Pointers to Members
          1. 15.5.1. Base and Derived Classes
        6. 15.6. Free Store
          1. 15.6.1. Array Allocation
          2. 15.6.2. “Virtual Constructors”
        7. 15.7. Advice
        8. 15.8. Exercises
    8. III. The Standard Library
      1. 16. Library Organization and Containers
        1. 16.1. Standard Library Design
          1. 16.1.1. Design Constraints
          2. 16.1.2. Standard Library Organization
          3. 16.1.3. Language Support
        2. 16.2. Container Design
          1. 16.2.1. Specialized Containers and Iterators
          2. 16.2.2. Based Containers
          3. 16.2.3. STL Containers
        3. 16.3. Vector
          1. 16.3.1. Types
          2. 16.3.2. Iterators
          3. 16.3.3. Element Access
          4. 16.3.4. Constructors
          5. 16.3.5. Stack Operations
          6. 16.3.6. List Operations
          7. 16.3.7. Addressing Elements
          8. 16.3.8. Size and Capacity
          9. 16.3.9. Other Member Functions
          10. 16.3.10. Helper Functions
          11. 16.3.11. Vector<bool>
        4. 16.4. Advice
        5. 16.5. Exercises
      2. 17. Standard Containers
        1. 17.1. Standard Containers
          1. 17.1.1. Operations Summary
          2. 17.1.2. Container Summary
          3. 17.1.3. Representation
          4. 17.1.4. Element Requirements
            1. 17.1.4.1. Comparisons
            2. 17.1.4.2. Other Relational Operators
        2. 17.2. Sequences
          1. 17.2.1. Vector
          2. 17.2.2. List
            1. 17.2.2.1. Splice, Sort, and Merge
            2. 17.2.2.2. Front Operations
            3. 17.2.2.3. Other Operations
          3. 17.2.3. Deque
        3. 17.3. Sequence Adapters
          1. 17.3.1. Stack
          2. 17.3.2. Queue
          3. 17.3.3. Priority Queue
        4. 17.4. Associative Containers
          1. 17.4.1. Map
            1. 17.4.1.1. Types
            2. 17.4.1.2. Iterators and Pairs
            3. 17.4.1.3. Subscripting
            4. 17.4.1.4. Constructors
            5. 17.4.1.5. Comparisons
            6. 17.4.1.6. Map Operations
            7. 17.4.1.7. List Operations
            8. 17.4.1.8. Other Functions
          2. 17.4.2. Multimap
          3. 17.4.3. Set
          4. 17.4.4. Multiset
        5. 17.5. Almost Containers
          1. 17.5.1. String
          2. 17.5.2. Valarray
          3. 17.5.3. Bitset
            1. 17.5.3.1. Constructors
            2. 17.5.3.2. Bit Manipulation Operations
            3. 17.5.3.3. Other Operations
          4. 17.5.4. Built-In Arrays
        6. 17.6. Defining a New Container
          1. 17.6.1. Hash_map
          2. 17.6.2. Representation and Construction
            1. 17.6.2.1. Lookup
            2. 17.6.2.2. Erase and Resize
            3. 17.6.2.3. Hashing
          3. 17.6.3. Other Hashed Associative Containers
        7. 17.7. Advice
        8. 17.8. Exercises
      3. 18. Algorithms and Function Objects
        1. 18.1. Introduction
        2. 18.2. Overview of Standard Library Algorithms
        3. 18.3. Sequences and Containers
          1. 18.3.1. Input Sequences
        4. 18.4. Function Objects
          1. 18.4.1. Function Object Bases
          2. 18.4.2. Predicates
            1. 18.4.2.1. Overview of Predicates
          3. 18.4.3. Arithmetic Function Objects
          4. 18.4.4. Binders, Adapters, and Negaters
            1. 18.4.4.1. Binders
            2. 18.4.4.2. Member Function Adapters
            3. 18.4.4.3. Pointer to Function Adapters
            4. 18.4.4.4. Negaters
        5. 18.5. Nonmodifying Sequence Algorithms
          1. 18.5.1. For_each
          2. 18.5.2. The Find Family
          3. 18.5.3. Count
          4. 18.5.4. Equal and Mismatch
          5. 18.5.5. Search
        6. 18.6. Modifying Sequence Algorithms
          1. 18.6.1. Copy
          2. 18.6.2. Transform
          3. 18.6.3. Unique
            1. 18.6.3.1. Sorting Criteria
          4. 18.6.4. Replace
          5. 18.6.5. Remove
          6. 18.6.6. Fill and Generate
          7. 18.6.7. Reverse and Rotate
          8. 18.6.8. Swap
        7. 18.7. Sorted Sequences
          1. 18.7.1. Sorting
          2. 18.7.2. Binary Search
          3. 18.7.3. Merge
          4. 18.7.4. Partitions
          5. 18.7.5. Set Operations on Sequences
        8. 18.8. Heaps
        9. 18.9. Min and Max
        10. 18.10. Permutations
        11. 18.11. C-Style Algorithms
        12. 18.12. Advice
        13. 18.13. Exercises
      4. 19. Iterators and Allocators
        1. 19.1. Introduction
        2. 19.2. Iterators and Sequences
          1. 19.2.1. Iterator Operations
          2. 19.2.2. Iterator Traits
          3. 19.2.3. Iterator Categories
          4. 19.2.4. Inserters
          5. 19.2.5. Reverse Iterators
          6. 19.2.6. Stream Iterators
            1. 19.2.6.1. Stream Buffers
        3. 19.3. Checked Iterators
          1. 19.3.1. Exceptions, Containers, and Algorithms
        4. 19.4. Allocators
          1. 19.4.1. The Standard Allocator
          2. 19.4.2. A User-Defined Allocator
          3. 19.4.3. Generalized Allocators
          4. 19.4.4. Uninitialized Memory
          5. 19.4.5. Dynamic Memory
          6. 19.4.6. C-Style Allocation
        5. 19.5. Advice
        6. 19.6. Exercises
      5. 20. Strings
        1. 20.1. Introduction
        2. 20.2. Characters
          1. 20.2.1. Character Traits
        3. 20.3. Basic_string
          1. 20.3.1. Types
          2. 20.3.2. Iterators
          3. 20.3.3. Element Access
          4. 20.3.4. Constructors
          5. 20.3.5. Errors
          6. 20.3.6. Assignment
          7. 20.3.7. Conversion to C-Style Strings
          8. 20.3.8. Comparisons
          9. 20.3.9. Insert
          10. 20.3.10. Concatenation
          11. 20.3.11. Find
          12. 20.3.12. Replace
          13. 20.3.13. Substrings
          14. 20.3.14. Size and Capacity
          15. 20.3.15. I/O Operations
          16. 20.3.16. Swap
        4. 20.4. The C Standard Library
          1. 20.4.1. C-Style Strings
          2. 20.4.2. Character Classification
        5. 20.5. Advice
        6. 20.6. Exercises
      6. 21. Streams
        1. 21.1. Introduction
        2. 21.2. Output
          1. 21.2.1. Output Streams
          2. 21.2.2. Output of Built-In Types
          3. 21.2.3. Output of User-Defined Types
            1. 21.2.3.1. Virtual Output Functions
        3. 21.3. Input
          1. 21.3.1. Input Streams
          2. 21.3.2. Input of Built-In Types
          3. 21.3.3. Stream State
          4. 21.3.4. Input of Characters
          5. 21.3.5. Input of User-Defined Types
          6. 21.3.6. Exceptions
          7. 21.3.7. Tying of Streams
          8. 21.3.8. Sentries
        4. 21.4. Formatting
          1. 21.4.1. Format State
            1. 21.4.1.1. Copying Format State
          2. 21.4.2. Integer Output
          3. 21.4.3. Floating-Point Output
          4. 21.4.4. Output Fields
          5. 21.4.5. Field Adjustment
          6. 21.4.6. Manipulators
            1. 21.4.6.1. Manipulators Taking Arguments
            2. 21.4.6.2. Standard I/O Manipulators
            3. 21.4.6.3. User-Defined Manipulators
        5. 21.5. File Streams and String Streams
          1. 21.5.1. File Streams
          2. 21.5.2. Closing of Streams
          3. 21.5.3. String Streams
        6. 21.6. Buffering
          1. 21.6.1. Output Streams and Buffers
          2. 21.6.2. Input Streams and Buffers
          3. 21.6.3. Streams and Buffers
          4. 21.6.4. Stream Buffers
        7. 21.7. Locale
          1. 21.7.1. Stream Callbacks
        8. 21.8. C Input/Output
        9. 21.9. Advice
        10. 21.10. Exercises
      7. 22. Numerics
        1. 22.1. Introduction
        2. 22.2. Numeric Limits
          1. 22.2.1. Limit Macros
        3. 22.3. Standard Mathematical Functions
        4. 22.4. Vector Arithmetic
          1. 22.4.1. Valarray Construction
          2. 22.4.2. Valarray Subscripting and Assignment
          3. 22.4.3. Member Operations
          4. 22.4.4. Nonmember Operations
          5. 22.4.5. Slices
          6. 22.4.6. Slice_array
          7. 22.4.7. Temporaries, Copying, and Loops
          8. 22.4.8. Generalized Slices
          9. 22.4.9. Masks
          10. 22.4.10. Indirect Arrays
        5. 22.5. Complex Arithmetic
        6. 22.6. Generalized Numeric Algorithms
          1. 22.6.1. Accumulate
          2. 22.6.2. Inner_product
          3. 22.6.3. Incremental Change
        7. 22.7. Random Numbers
        8. 22.8. Advice
        9. 22.9. Exercises
    9. IV. Design Using C++
      1. 23. Development and Design
        1. 23.1. Overview
        2. 23.2. Introduction
        3. 23.3. Aims and Means
        4. 23.4. The Development Process
          1. 23.4.1. The Development Cycle
          2. 23.4.2. Design Aims
          3. 23.4.3. Design Steps
            1. 23.4.3.1. Step 1: Find Classes
            2. 23.4.3.2. Step 2: Specify Operations
            3. 23.4.3.3. Step 3: Specify Dependencies
            4. 23.4.3.4. Step 4: Specify Interfaces
            5. 23.4.3.5. Reorganization of Class Hierarchies
            6. 23.4.3.6. Use of Models
          4. 23.4.4. Experimentation and Analysis
          5. 23.4.5. Testing
          6. 23.4.6. Software Maintenance
          7. 23.4.7. Efficiency
        5. 23.5. Management
          1. 23.5.1. Reuse
          2. 23.5.2. Scale
          3. 23.5.3. Individuals
          4. 23.5.4. Hybrid Design
        6. 23.6. Annotated Bibliography
        7. 23.7. Advice
      2. 24. Design and Programming
        1. 24.1. Overview
        2. 24.2. Design and Programming Language
          1. 24.2.1. Ignoring Classes
          2. 24.2.2. Avoiding Inheritance
          3. 24.2.3. Ignoring Static Type Checking
          4. 24.2.4. Avoiding Programming
          5. 24.2.5. Using Class Hierarchies Exclusively
        3. 24.3. Classes
          1. 24.3.1. What Do Classes Represent?
          2. 24.3.2. Class Hierarchies
            1. 24.3.2.1. Dependencies within a Class Hierarchy
          3. 24.3.3. Containment Relationships
          4. 24.3.4. Containment and Inheritance
            1. 24.3.4.1. Member/Hierarchy Tradeoffs
            2. 24.3.4.2. Containment/Hierarchy Tradeoffs
          5. 24.3.5. Use Relationships
          6. 24.3.6. Programmed-In Relationships
          7. 24.3.7. Relationships within a Class
            1. 24.3.7.1. Invariants
            2. 24.3.7.2. Assertions
            3. 24.3.7.3. Preconditions and Postconditions
            4. 24.3.7.4. Encapsulation
        4. 24.4. Components
          1. 24.4.1. Templates
          2. 24.4.2. Interfaces and Implementations
          3. 24.4.3. Fat Interfaces
        5. 24.5. Advice
      3. 25. Roles of Classes
        1. 25.1. Kinds of Classes
        2. 25.2. Concrete Types
          1. 25.2.1. Reuse of Concrete Types
        3. 25.3. Abstract Types
        4. 25.4. Node Classes
          1. 25.4.1. Changing Interfaces
        5. 25.5. Actions
        6. 25.6. Interface Classes
          1. 25.6.1. Adjusting Interfaces
        7. 25.7. Handle Classes
          1. 25.7.1. Operations in Handles
        8. 25.8. Application Frameworks
        9. 25.9. Advice
        10. 25.10. Exercises
    10. Appendices and Index
      1. A. Grammar
        1. A.1. Introduction
        2. A.2. Keywords
        3. A.3. Lexical Conventions
        4. A.4. Programs
        5. A.5. Expressions
        6. A.6. Statements
        7. A.7. Declarations
          1. A.7.1. Declarators
        8. A.8. Classes
          1. A.8.1. Derived Classes
          2. A.8.2. Special Member Functions
          3. A.8.3. Overloading
        9. A.9. Templates
        10. A.10. Exception Handling
        11. A.11. Preprocessing Directives
      2. B. Compatibility
        1. B.1. Introduction
        2. B.2. C/C++ Compatibility
          1. B.2.1. “Silent” Differences
          2. B.2.2. C Code That Is Not C++
          3. B.2.3. Deprecated Features
          4. B.2.4. C++ Code That Is Not C
        3. B.3. Coping with Older C++ Implementations
          1. B.3.1. Headers
          2. B.3.2. The Standard Library
          3. B.3.3. Namespaces
          4. B.3.4. Allocation Errors
          5. B.3.5. Templates
          6. B.3.6. For-Statement Initializers
        4. B.4. Advice
        5. B.5. Exercises
      3. C. Technicalities
        1. C.1. Introduction and Overview
        2. C.2. The Standard
        3. C.3. Character Sets
          1. C.3.1. Restricted Character Sets
          2. C.3.2. Escape Characters
          3. C.3.3. Large Character Sets
          4. C.3.4. Signed and Unsigned Characters
        4. C.4. Types of Integer Literals
        5. C.5. Constant Expressions
        6. C.6. Implicit Type Conversion
          1. C.6.1. Promotions
          2. C.6.2. Conversions
            1. C.6.2.1. Integral Conversions
            2. C.6.2.2. Floating-Point Conversions
            3. C.6.2.3. Pointer and Reference Conversions
            4. C.6.2.4. Pointer-to-Member Conversions
            5. C.6.2.5. Boolean Conversions
            6. C.6.2.6. Floating-Integral Conversions
          3. C.6.3. Usual Arithmetic Conversions
        7. C.7. Multidimensional Arrays
          1. C.7.1. Vectors
          2. C.7.2. Arrays
          3. C.7.3. Passing Multidimensional Arrays
        8. C.8. Saving Space
          1. C.8.1. Fields
          2. C.8.2. Unions
          3. C.8.3. Unions and Classes
        9. C.9. Memory Management
          1. C.9.1. Automatic Garbage Collection
            1. C.9.1.1. Disguised Pointers
            2. C.9.1.2. Delete
            3. C.9.1.3. Destructors
            4. C.9.1.4. Memory Fragmentation
        10. C.10. Namespaces
          1. C.10.1. Convenience vs. Safety
          2. C.10.2. Nesting of Namespaces
          3. C.10.3. Namespaces and Classes
        11. C.11. Access Control
          1. C.11.1. Access to Members
          2. C.11.2. Access to Base Classes
          3. C.11.3. Access to Member Class
          4. C.11.4. Friendship
        12. C.12. Pointers to Data Members
        13. C.13. Templates
          1. C.13.1. Static Members
          2. C.13.2. Friends
          3. C.13.3. Templates as Template Parameters
          4. C.13.4. Deducing Function Template Arguments
          5. C.13.5. Typename and Template
          6. C.13.6. Template as a Qualifier
          7. C.13.7. Instantiation
          8. C.13.8. Name Binding
            1. C.13.8.1. Dependent Names
            2. C.13.8.2. Point of Definition Binding
            3. C.13.8.3. Point of Instantiation Binding
            4. C.13.8.4. Templates and Namespaces
          9. C.13.9. When Is a Specialization Needed?
            1. C.13.9.1. Template Function Instantiation
          10. C.13.10. Explicit Instantiation
        14. C.14. Advice
      4. D. Locales
        1. D.1. Handling Cultural Differences
          1. D.1.1. Programming Cultural Differences
        2. D.2. The locale Class
          1. D.2.1. Named Locales
            1. D.2.1.1. Constructing New Locales
          2. D.2.2. Copying and Comparing Locales
          3. D.2.3. The global() and the classic() Locales
          4. D.2.4. Comparing Strings
        3. D.3. Facets
          1. D.3.1. Accessing Facets in a Locale
          2. D.3.2. A Simple User-Defined Facet
          3. D.3.3. Uses of Locales and Facets
        4. D.4. Standard Facets
          1. D.4.1. String Comparison
            1. D.4.1.1. Named Collate
          2. D.4.2. Numeric Input and Output
            1. D.4.2.1. Numeric Punctuation
            2. D.4.2.2. Numeric Output
            3. D.4.2.3. Numeric Input
          3. D.4.3. Input and Output of Monetary Values
            1. D.4.3.1. Money Punctuation
            2. D.4.3.2. Money Output
            3. D.4.3.3. Money Input
          4. D.4.4. Date and Time Input and Output
            1. D.4.4.1. Clocks and Timers
            2. D.4.4.2. A Date Class
            3. D.4.4.3. Date and Time Output
            4. D.4.4.4. Date and Time Input
            5. D.4.4.5. A More Flexible Date Class
            6. D.4.4.6. Specifying a Date Format
            7. D.4.4.7. A Date Input Facet
          5. D.4.5. Character Classification
            1. D.4.5.1. Convenience Interfaces
          6. D.4.6. Character Code Conversion
          7. D.4.7. Messages
            1. D.4.7.1. Using Messages from Other Facets
        5. D.5. Advice
        6. D.6. Exercises
      5. E. Standard-Library Exception Safety
        1. E.1. Introduction
        2. E.2. Exception Safety
        3. E.3. Exception-Safe Implementation Techniques
          1. E.3.1. A Simple Vector
          2. E.3.2. Representing Memory Explicitly
          3. E.3.3. Assignment
          4. E.3.4. push_back()
          5. E.3.5. Constructors and Invariants
            1. E.3.5.1. Using init() Functions
            2. E.3.5.2. Relying on a Default Valid State
            3. E.3.5.3. Delaying resource acquisition
        4. E.4. Standard Container Guarantees
          1. E.4.1. Insertion and Removal of Elements
          2. E.4.2. Guarantees and Tradeoffs
          3. E.4.3. Swap
          4. E.4.4. Initialization and Iterators
          5. E.4.5. References to Elements
          6. E.4.6. Predicates
        5. E.5. The Rest of the Standard Library
          1. E.5.1. Strings
          2. E.5.2. Streams
          3. E.5.3. Algorithms
          4. E.5.4. Valarray and Complex
          5. E.5.5. The C Standard Library
        6. E.6. Implications for Library Users
        7. E.7. Advice
        8. E.8. Exercises

    Product information

    • Title: The C++ Programming Language, Special Edition
    • Author(s): New Jersey Stroustrup Bjarne AT&T Labs Murray Hill
    • Release date: February 2000
    • Publisher(s): Addison-Wesley Professional
    • ISBN: 0201700735