C++ Primer, Fifth Edition

Book description

Bestselling Programming Tutorial and Reference Completely Rewritten for the New C++11 Standard

Fully updated and recast for the newly released C++11 standard, this authoritative and comprehensive introduction to C++ will help you to learn the language fast, and to use it in modern, highly effective ways. Highlighting today’s best practices, the authors show how to use both the core language and its standard library to write efficient, readable, and powerful code.

C++ Primer, Fifth Edition, introduces the C++ standard library from the outset, drawing on its common functions and facilities to help you write useful programs without first having to master every language detail. The book’s many examples have been revised to use the new language features and demonstrate how to make the best use of them. This book is a proven tutorial for those new to C++, an authoritative discussion of core C++ concepts and techniques, and a valuable resource for experienced programmers, especially those eager to see C++11 enhancements illuminated.

Start Fast and Achieve More

  • Learn how to use the new C++11 language features and the standard library to build robust programs quickly, and get comfortable with high-level programming

  • Learn through examples that illuminate today’s best coding styles and program design techniques

  • Understand the “rationale behind the rules”: why C++11 works as it does

  • Use the extensive crossreferences to help you connect related concepts and insights

  • Benefit from up-to-date learning aids and exercises that emphasize key points, help you to avoid pitfalls, promote good practices, and reinforce what you’ve learned

  • Access the source code for the extended examples from informit.com/title/0321714113

    C++ Primer, Fifth Edition, features an enhanced, layflat binding, which allows the book to stay open more easily when placed on a flat surface. This special binding method—notable by a small space inside the spine—also increases durability.

    Table of contents

    1. Title Page
    2. Copyright Page
    3. Dedication Page
    4. Contents
    5. New Features in C++11
    6. Preface
      1. Why Read This Book?
      2. Changes to the Fifth Edition
      3. Structure of This Book
      4. Aids to the Reader
      5. A Note about Compilers
      6. Acknowledgments
    7. Chapter 1. Getting Started
      1. Contents
      2. 1.1. Writing a Simple C++ Program
        1. 1.1.1. Compiling and Executing Our Program
      3. 1.2. A First Look at Input/Output
        1. Standard Input and Output Objects
        2. A Program That Uses the IO Library
        3. Writing to a Stream
        4. Using Names from the Standard Library
        5. Reading from a Stream
        6. Completing the Program
      4. 1.3. A Word about Comments
        1. Kinds of Comments in C++
        2. Comment Pairs Do Not Nest
      5. 1.4. Flow of Control
        1. 1.4.1. The while Statement
        2. 1.4.2. The for Statement
        3. 1.4.3. Reading an Unknown Number of Inputs
        4. 1.4.4. The if Statement
      6. 1.5. Introducing Classes
        1. 1.5.1. The Sales_item Class
        2. 1.5.2. A First Look at Member Functions
      7. 1.6. The Bookstore Program
      8. Chapter Summary
      9. Defined Terms
    8. Part I. The Basics
      1. Contents
      2. Chapter 2. Variables and Basic Types
        1. Contents
        2. 2.1. Primitive Built-in Types
          1. 2.1.1. Arithmetic Types
          2. 2.1.2. Type Conversions
          3. 2.1.3. Literals
        3. 2.2. Variables
          1. 2.2.1. Variable Definitions
          2. 2.2.2. Variable Declarations and Definitions
          3. 2.2.3. Identifiers
          4. 2.2.4. Scope of a Name
        4. 2.3. Compound Types
          1. 2.3.1. References
          2. 2.3.2. Pointers
          3. 2.3.3. Understanding Compound Type Declarations
        5. 2.4. const Qualifier
          1. Initialization and const
          2. By Default, const Objects Are Local to a File
          3. 2.4.1. References to const
          4. 2.4.2. Pointers and const
          5. 2.4.3. Top-Level const
          6. 2.4.4. constexpr and Constant Expressions
        6. 2.5. Dealing with Types
          1. 2.5.1. Type Aliases
          2. 2.5.2. The auto Type Specifier
          3. 2.5.3. The decltype Type Specifier
        7. 2.6. Defining Our Own Data Structures
          1. 2.6.1. Defining the Sales_data Type
          2. 2.6.2. Using the Sales_data Class
          3. 2.6.3. Writing Our Own Header Files
        8. Chapter Summary
        9. Defined Terms
      3. Chapter 3. Strings, Vectors, and Arrays
        1. Contents
        2. 3.1. Namespace using Declarations
          1. A Separate using Declaration Is Required for Each Name
          2. Headers Should Not Include using Declarations
          3. A Note to the Reader
        3. 3.2. Library string Type
          1. 3.2.1. Defining and Initializing strings
          2. 3.2.2. Operations on strings
          3. 3.2.3. Dealing with the Characters in a string
        4. 3.3. Library vector Type
          1. 3.3.1. Defining and Initializing vectors
          2. 3.3.2. Adding Elements to a vector
          3. 3.3.3. Other vector Operations
        5. 3.4. Introducing Iterators
          1. 3.4.1. Using Iterators
          2. 3.4.2. Iterator Arithmetic
        6. 3.5. Arrays
          1. 3.5.1. Defining and Initializing Built-in Arrays
          2. 3.5.2. Accessing the Elements of an Array
          3. 3.5.3. Pointers and Arrays
          4. 3.5.4. C-Style Character Strings
          5. 3.5.5. Interfacing to Older Code
        7. 3.6. Multidimensional Arrays
          1. Initializing the Elements of a Multidimensional Array
          2. Subscripting a Multidimensional Array
          3. Using a Range for with Multidimensional Arrays
          4. Pointers and Multidimensional Arrays
          5. Type Aliases Simplify Pointers to Multidimensional Arrays
        8. Chapter Summary
        9. Defined Terms
      4. Chapter 4. Expressions
        1. Contents
        2. 4.1. Fundamentals
          1. 4.1.1. Basic Concepts
          2. 4.1.2. Precedence and Associativity
          3. 4.1.3. Order of Evaluation
        3. 4.2. Arithmetic Operators
        4. 4.3. Logical and Relational Operators
          1. Logical AND and OR Operators
          2. Logical NOT Operator
          3. The Relational Operators
          4. Equality Tests and the bool Literals
        5. 4.4. Assignment Operators
          1. Assignment Is Right Associative
          2. Assignment Has Low Precedence
          3. Beware of Confusing Equality and Assignment Operators
          4. Compound Assignment Operators
        6. 4.5. Increment and Decrement Operators
          1. Combining Dereference and Increment in a Single Expression
          2. Remember That Operands Can Be Evaluated in Any Order
        7. 4.6. The Member Access Operators
        8. 4.7. The Conditional Operator
          1. Nesting Conditional Operations
          2. Using a Conditional Operator in an Output Expression
        9. 4.8. The Bitwise Operators
          1. Bitwise Shift Operators
          2. Bitwise NOT Operator
          3. Bitwise AND, OR, and XOR Operators
          4. Using Bitwise Operators
          5. Shift Operators (aka IO Operators) Are Left Associative
        10. 4.9. The sizeof Operator
        11. 4.10. Comma Operator
        12. 4.11. Type Conversions
          1. When Implicit Conversions Occur
          2. 4.11.1. The Arithmetic Conversions
          3. 4.11.2. Other Implicit Conversions
          4. 4.11.3. Explicit Conversions
        13. 4.12. Operator Precedence Table
        14. Chapter Summary
        15. Defined Terms
      5. Chapter 5. Statements
        1. Contents
        2. 5.1. Simple Statements
          1. Null Statements
          2. Beware of Missing or Extraneous Semicolons
          3. Compound Statements (Blocks)
        3. 5.2. Statement Scope
        4. 5.3. Conditional Statements
          1. 5.3.1. The if Statement
          2. 5.3.2. The switch Statement
        5. 5.4. Iterative Statements
          1. 5.4.1. The while Statement
          2. 5.4.2. Traditional for Statement
          3. 5.4.3. Range for Statement
          4. 5.4.4. The do while Statement
        6. 5.5. Jump Statements
          1. 5.5.1. The break Statement
          2. 5.5.2. The continue Statement
          3. 5.5.3. The goto Statement
        7. 5.6. try Blocks and Exception Handling
          1. 5.6.1. A throw Expression
          2. 5.6.2. The try Block
          3. 5.6.3. Standard Exceptions
        8. Chapter Summary
        9. Defined Terms
      6. Chapter 6. Functions
        1. Contents
        2. 6.1. Function Basics
          1. Writing a Function
          2. Calling a Function
          3. Parameters and Arguments
          4. Function Parameter List
          5. Function Return Type
          6. 6.1.1. Local Objects
          7. 6.1.2. Function Declarations
          8. 6.1.3. Separate Compilation
        3. 6.2. Argument Passing
          1. 6.2.1. Passing Arguments by Value
          2. 6.2.2. Passing Arguments by Reference
          3. 6.2.3. const Parameters and Arguments
          4. 6.2.4. Array Parameters
          5. 6.2.5. main: Handling Command-Line Options
          6. 6.2.6. Functions with Varying Parameters
        4. 6.3. Return Types and the return Statement
          1. 6.3.1. Functions with No Return Value
          2. 6.3.2. Functions That Return a Value
          3. 6.3.3. Returning a Pointer to an Array
        5. 6.4. Overloaded Functions
          1. Defining Overloaded Functions
          2. Determining Whether Two Parameter Types Differ
          3. Overloading and const Parameters
          4. const_cast and Overloading
          5. Calling an Overloaded Function
          6. 6.4.1. Overloading and Scope
        6. 6.5. Features for Specialized Uses
          1. 6.5.1. Default Arguments
          2. 6.5.2. Inline and constexpr Functions
          3. 6.5.3. Aids for Debugging
        7. 6.6. Function Matching
          1. Determining the Candidate and Viable Functions
          2. Finding the Best Match, If Any
          3. Function Matching with Multiple Parameters
          4. 6.6.1. Argument Type Conversions
        8. 6.7. Pointers to Functions
          1. Using Function Pointers
          2. Pointers to Overloaded Functions
          3. Function Pointer Parameters
          4. Returning a Pointer to Function
          5. Using auto or decltype for Function Pointer Types
        9. Chapter Summary
        10. Defined Terms
      7. Chapter 7. Classes
        1. Contents
        2. 7.1. Defining Abstract Data Types
          1. 7.1.1. Designing the Sales_data Class
          2. 7.1.2. Defining the Revised Sales_data Class
          3. 7.1.3. Defining Nonmember Class-Related Functions
          4. 7.1.4. Constructors
          5. 7.1.5. Copy, Assignment, and Destruction
        3. 7.2. Access Control and Encapsulation
          1. Using the class or struct Keyword
          2. 7.2.1. Friends
        4. 7.3. Additional Class Features
          1. 7.3.1. Class Members Revisited
          2. 7.3.2. Functions That Return *this
          3. 7.3.3. Class Types
          4. 7.3.4. Friendship Revisited
        5. 7.4. Class Scope
          1. Scope and Members Defined outside the Class
          2. 7.4.1. Name Lookup and Class Scope
        6. 7.5. Constructors Revisited
          1. 7.5.1. Constructor Initializer List
          2. 7.5.2. Delegating Constructors
          3. 7.5.3. The Role of the Default Constructor
          4. 7.5.4. Implicit Class-Type Conversions
          5. 7.5.5. Aggregate Classes
          6. 7.5.6. Literal Classes
        7. 7.6. static Class Members
          1. Declaring static Members
          2. Using a Class static Member
          3. Defining static Members
          4. In-Class Initialization of static Data Members
          5. static Members Can Be Used in Ways Ordinary Members Can’t
        8. Chapter Summary
        9. Defined Terms
    9. Part II. The C++ Library
      1. Contents
      2. Chapter 8. The IO Library
        1. Contents
        2. 8.1. The IO Classes
          1. Relationships among the IO Types
          2. 8.1.1. No Copy or Assign for IO Objects
          3. 8.1.2. Condition States
          4. 8.1.3. Managing the Output Buffer
        3. 8.2. File Input and Output
          1. 8.2.1. Using File Stream Objects
          2. 8.2.2. File Modes
        4. 8.3. string Streams
          1. 8.3.1. Using an istringstream
          2. 8.3.2. Using ostringstreams
        5. Chapter Summary
        6. Defined Terms
      3. Chapter 9. Sequential Containers
        1. Contents
        2. 9.1. Overview of the Sequential Containers
          1. Deciding Which Sequential Container to Use
        3. 9.2. Container Library Overview
          1. Constraints on Types That a Container Can Hold
          2. 9.2.1. Iterators
          3. 9.2.2. Container Type Members
          4. 9.2.3. begin and end Members
          5. 9.2.4. Defining and Initializing a Container
          6. 9.2.5. Assignment and swap
          7. 9.2.6. Container Size Operations
          8. 9.2.7. Relational Operators
        4. 9.3. Sequential Container Operations
          1. 9.3.1. Adding Elements to a Sequential Container
          2. 9.3.2. Accessing Elements
          3. 9.3.3. Erasing Elements
          4. 9.3.4. Specialized forward_list Operations
          5. 9.3.5. Resizing a Container
          6. 9.3.6. Container Operations May Invalidate Iterators
        5. 9.4. How a vector Grows
          1. Members to Manage Capacity
          2. capacity and size
        6. 9.5. Additional string Operations
          1. 9.5.1. Other Ways to Construct strings
          2. 9.5.2. Other Ways to Change a string
          3. 9.5.3. string Search Operations
          4. 9.5.4. The compare Functions
          5. 9.5.5. Numeric Conversions
        7. 9.6. Container Adaptors
          1. Defining an Adaptor
          2. Stack Adaptor
          3. The Queue Adaptors
        8. Chapter Summary
        9. Defined Terms
      4. Chapter 10. Generic Algorithms
        1. Contents
        2. 10.1. Overview
          1. How the Algorithms Work
          2. Iterators Make the Algorithms Container Independent, ...
          3. ...But Algorithms Do Depend on Element-Type Operations
        3. 10.2. A First Look at the Algorithms
          1. 10.2.1. Read-Only Algorithms
          2. 10.2.2. Algorithms That Write Container Elements
          3. 10.2.3. Algorithms That Reorder Container Elements
        4. 10.3. Customizing Operations
          1. 10.3.1. Passing a Function to an Algorithm
          2. 10.3.2. Lambda Expressions
          3. 10.3.3. Lambda Captures and Returns
          4. 10.3.4. Binding Arguments
        5. 10.4. Revisiting Iterators
          1. 10.4.1. Insert Iterators
          2. 10.4.2. iostream Iterators
          3. 10.4.3. Reverse Iterators
        6. 10.5. Structure of Generic Algorithms
          1. 10.5.1. The Five Iterator Categories
          2. 10.5.2. Algorithm Parameter Patterns
          3. 10.5.3. Algorithm Naming Conventions
        7. 10.6. Container-Specific Algorithms
          1. The splice Members
          2. The List-Specific Operations Do Change the Containers
        8. Chapter Summary
        9. Defined Terms
      5. Chapter 11. Associative Containers
        1. Contents
        2. 11.1. Using an Associative Container
          1. Using a map
          2. Using a set
        3. 11.2. Overview of the Associative Containers
          1. 11.2.1. Defining an Associative Container
          2. 11.2.2. Requirements on Key Type
          3. 11.2.3. The pair Type
        4. 11.3. Operations on Associative Containers
          1. 11.3.1. Associative Container Iterators
          2. 11.3.2. Adding Elements
          3. 11.3.3. Erasing Elements
          4. 11.3.4. Subscripting a map
          5. 11.3.5. Accessing Elements
          6. 11.3.6. A Word Transformation Map
        5. 11.4. The Unordered Containers
          1. Using an Unordered Container
          2. Managing the Buckets
          3. Requirements on Key Type for Unordered Containers
        6. Chapter Summary
        7. Defined Terms
      6. Chapter 12. Dynamic Memory
        1. Contents
        2. 12.1. Dynamic Memory and Smart Pointers
          1. 12.1.1. The shared_ptr Class
          2. 12.1.2. Managing Memory Directly
          3. 12.1.3. Using shared_ptrs with new
          4. 12.1.4. Smart Pointers and Exceptions
          5. 12.1.5. unique_ptr
          6. 12.1.6. weak_ptr
        3. 12.2. Dynamic Arrays
          1. 12.2.1. new and Arrays
          2. 12.2.2. The allocator Class
        4. 12.3. Using the Library: A Text-Query Program
          1. 12.3.1. Design of the Query Program
          2. 12.3.2. Defining the Query Program Classes
        5. Chapter Summary
        6. Defined Terms
    10. Part III. Tools for Class Authors
      1. Contents
      2. Chapter 13. Copy Control
        1. Contents
        2. 13.1. Copy, Assign, and Destroy
          1. 13.1.1. The Copy Constructor
          2. 13.1.2. The Copy-Assignment Operator
          3. 13.1.3. The Destructor
          4. 13.1.4. The Rule of Three/Five
          5. 13.1.5. Using = default
          6. 13.1.6. Preventing Copies
        3. 13.2. Copy Control and Resource Management
          1. 13.2.1. Classes That Act Like Values
          2. 13.2.2. Defining Classes That Act Like Pointers
        4. 13.3. Swap
          1. Writing Our Own swap Function
          2. swap Functions Should Call swap, Not std::swap
          3. Using swap in Assignment Operators
        5. 13.4. A Copy-Control Example
          1. The Message Class
          2. The save and remove Members
          3. Copy Control for the Message Class
          4. The Message Destructor
          5. Message Copy-Assignment Operator
          6. A swap Function for Message
        6. 13.5. Classes That Manage Dynamic Memory
          1. StrVec Class Design
          2. StrVec Class Definition
          3. Using construct
          4. The alloc_n_copy Member
          5. The free Member
          6. Copy-Control Members
          7. Moving, Not Copying, Elements during Reallocation
          8. Move Constructors and std::move
          9. The reallocate Member
        7. 13.6. Moving Objects
          1. 13.6.1. Rvalue References
          2. 13.6.2. Move Constructor and Move Assignment
          3. 13.6.3. Rvalue References and Member Functions
        8. Chapter Summary
        9. Defined Terms
      3. Chapter 14. Overloaded Operations and Conversions
        1. Contents
        2. 14.1. Basic Concepts
          1. Calling an Overloaded Operator Function Directly
          2. Some Operators Shouldn’t Be Overloaded
          3. Use Definitions That Are Consistent with the Built-in Meaning
          4. Assignment and Compound Assignment Operators
          5. Choosing Member or Nonmember Implementation
        3. 14.2. Input and Output Operators
          1. 14.2.1. Overloading the Output Operator <<
          2. 14.2.2. Overloading the Input Operator >>
        4. 14.3. Arithmetic and Relational Operators
          1. 14.3.1. Equality Operators
          2. 14.3.2. Relational Operators
        5. 14.4. Assignment Operators
          1. Compound-Assignment Operators
        6. 14.5. Subscript Operator
        7. 14.6. Increment and Decrement Operators
          1. Defining Prefix Increment/Decrement Operators
          2. Differentiating Prefix and Postfix Operators
          3. Calling the Postfix Operators Explicitly
        8. 14.7. Member Access Operators
          1. Constraints on the Return from Operator Arrow
        9. 14.8. Function-Call Operator
          1. Function-Object Classes with State
          2. 14.8.1. Lambdas Are Function Objects
          3. 14.8.2. Library-Defined Function Objects
          4. 14.8.3. Callable Objects and function
        10. 14.9. Overloading, Conversions, and Operators
          1. 14.9.1. Conversion Operators
          2. 14.9.2. Avoiding Ambiguous Conversions
          3. 14.9.3. Function Matching and Overloaded Operators
        11. Chapter Summary
        12. Defined Terms
      4. Chapter 15. Object-Oriented Programming
        1. Contents
        2. 15.1. OOP: An Overview
          1. Inheritance
          2. Dynamic Binding
        3. 15.2. Defining Base and Derived Classes
          1. 15.2.1. Defining a Base Class
          2. 15.2.2. Defining a Derived Class
          3. 15.2.3. Conversions and Inheritance
        4. 15.3. Virtual Functions
          1. Calls to Virtual Functions May Be Resolved at Run Time
          2. Virtual Functions in a Derived Class
          3. The final and override Specifiers
          4. Virtual Functions and Default Arguments
          5. Circumventing the Virtual Mechanism
        5. 15.4. Abstract Base Classes
          1. Pure Virtual Functions
          2. Classes with Pure Virtuals Are Abstract Base Classes
          3. A Derived Class Constructor Initializes Its Direct Base Class Only
        6. 15.5. Access Control and Inheritance
          1. protected Members
          2. public, private, and protected
          3. Accessibility of Derived-to-Base Conversion
          4. Friendship and Inheritance
          5. Exempting Individual Members
          6. Default Inheritance Protection Levels
        7. 15.6. Class Scope under Inheritance
          1. Name Lookup Happens at Compile Time
          2. Name Collisions and Inheritance
          3. Using the Scope Operator to Use Hidden Members
          4. As Usual, Name Lookup Happens before Type Checking
          5. Virtual Functions and Scope
          6. Calling a Hidden Virtual through the Base Class
          7. Overriding Overloaded Functions
        8. 15.7. Constructors and Copy Control
          1. 15.7.1. Virtual Destructors
          2. 15.7.2. Synthesized Copy Control and Inheritance
          3. 15.7.3. Derived-Class Copy-Control Members
          4. 15.7.4. Inherited Constructors
        9. 15.8. Containers and Inheritance
          1. Put (Smart) Pointers, Not Objects, in Containers
          2. 15.8.1. Writing a Basket Class
        10. 15.9. Text Queries Revisited
          1. 15.9.1. An Object-Oriented Solution
          2. 15.9.2. The Query_base and Query Classes
          3. 15.9.3. The Derived Classes
          4. 15.9.4. The eval Functions
        11. Chapter Summary
        12. Defined Terms
      5. Chapter 16. Templates and Generic Programming
        1. Contents
        2. 16.1. Defining a Template
          1. 16.1.1. Function Templates
          2. 16.1.2. Class Templates
          3. 16.1.3. Template Parameters
          4. 16.1.4. Member Templates
          5. 16.1.5. Controlling Instantiations
          6. 16.1.6. Efficiency and Flexibility
        3. 16.2. Template Argument Deduction
          1. 16.2.1. Conversions and Template Type Parameters
          2. 16.2.2. Function-Template Explicit Arguments
          3. 16.2.3. Trailing Return Types and Type Transformation
          4. 16.2.4. Function Pointers and Argument Deduction
          5. 16.2.5. Template Argument Deduction and References
          6. 16.2.6. Understanding std::move
          7. 16.2.7. Forwarding
        4. 16.3. Overloading and Templates
          1. Writing Overloaded Templates
          2. Multiple Viable Templates
          3. Nontemplate and Template Overloads
          4. Overloaded Templates and Conversions
          5. Missing Declarations Can Cause the Program to Misbehave
        5. 16.4. Variadic Templates
          1. The sizeof... Operator
          2. 16.4.1. Writing a Variadic Function Template
          3. 16.4.2. Pack Expansion
          4. 16.4.3. Forwarding Parameter Packs
        6. 16.5. Template Specializations
          1. Defining a Function Template Specialization
          2. Function Overloading versus Template Specializations
          3. Class Template Specializations
          4. Class-Template Partial Specializations
          5. Specializing Members but Not the Class
        7. Chapter Summary
        8. Defined Terms
    11. Part IV. Advanced Topics
      1. Contents
      2. Chapter 17. Specialized Library Facilities
        1. Contents
        2. 17.1. The tuple Type
          1. 17.1.1. Defining and Initializing tuples
          2. 17.1.2. Using a tuple to Return Multiple Values
        3. 17.2. The bitset Type
          1. 17.2.1. Defining and Initializing bitsets
          2. 17.2.2. Operations on bitsets
        4. 17.3. Regular Expressions
          1. 17.3.1. Using the Regular Expression Library
          2. 17.3.2. The Match and Regex Iterator Types
          3. 17.3.3. Using Subexpressions
          4. 17.3.4. Using regex_replace
        5. 17.4. Random Numbers
          1. 17.4.1. Random-Number Engines and Distribution
          2. 17.4.2. Other Kinds of Distributions
        6. 17.5. The IO Library Revisited
          1. 17.5.1. Formatted Input and Output
          2. 17.5.2. Unformatted Input/Output Operations
          3. 17.5.3. Random Access to a Stream
        7. Chapter Summary
        8. Defined Terms
      3. Chapter 18. Tools for Large Programs
        1. Contents
        2. 18.1. Exception Handling
          1. 18.1.1. Throwing an Exception
          2. 18.1.2. Catching an Exception
          3. 18.1.3. Function try Blocks and Constructors
          4. 18.1.4. The noexcept Exception Specification
          5. 18.1.5. Exception Class Hierarchies
        3. 18.2. Namespaces
          1. 18.2.1. Namespace Definitions
          2. 18.2.2. Using Namespace Members
          3. 18.2.3. Classes, Namespaces, and Scope
          4. 18.2.4. Overloading and Namespaces
        4. 18.3. Multiple and Virtual Inheritance
          1. 18.3.1. Multiple Inheritance
          2. 18.3.2. Conversions and Multiple Base Classes
          3. 18.3.3. Class Scope under Multiple Inheritance
          4. 18.3.4. Virtual Inheritance
          5. 18.3.5. Constructors and Virtual Inheritance
        5. Chapter Summary
        6. Defined Terms
      4. Chapter 19. Specialized Tools and Techniques
        1. Contents
        2. 19.1. Controlling Memory Allocation
          1. 19.1.1. Overloading new and delete
          2. 19.1.2. Placement new Expressions
        3. 19.2. Run-Time Type Identification
          1. 19.2.1. The dynamic_cast Operator
          2. 19.2.2. The typeid Operator
          3. 19.2.3. Using RTTI
          4. 19.2.4. The type_info Class
        4. 19.3. Enumerations
          1. Enumerators
          2. Like Classes, Enumerations Define New Types
          3. Specifying the Size of an enum
          4. Forward Declarations for Enumerations
          5. Parameter Matching and Enumerations
        5. 19.4. Pointer to Class Member
          1. 19.4.1. Pointers to Data Members
          2. 19.4.2. Pointers to Member Functions
          3. 19.4.3. Using Member Functions as Callable Objects
        6. 19.5. Nested Classes
          1. Declaring a Nested Class
          2. Defining a Nested Class outside of the Enclosing Class
          3. Defining the Members of a Nested Class
          4. Nested-Class static Member Definitions
          5. Name Lookup in Nested Class Scope
          6. The Nested and Enclosing Classes Are Independent
        7. 19.6. union: A Space-Saving Class
          1. Defining a union
          2. Using a union Type
          3. Anonymous unions
          4. unions with Members of Class Type
          5. Using a Class to Manage union Members
          6. Managing the Discriminant and Destroying the string
          7. Managing Union Members That Require Copy Control
        8. 19.7. Local Classes
          1. Local Classes May Not Use Variables from the Function’s Scope
          2. Normal Protection Rules Apply to Local Classes
          3. Name Lookup within a Local Class
          4. Nested Local Classes
        9. 19.8. Inherently Nonportable Features
          1. 19.8.1. Bit-fields
          2. 19.8.2. volatile Qualifier
          3. 19.8.3. Linkage Directives: extern "C"
        10. Chapter Summary
        11. Defined Terms
    12. Appendix A. The Library
      1. Contents
      2. A.1. Library Names and Headers
      3. A.2. A Brief Tour of the Algorithms
        1. A.2.1. Algorithms to Find an Object
        2. A.2.2. Other Read-Only Algorithms
        3. A.2.3. Binary Search Algorithms
        4. A.2.4. Algorithms That Write Container Elements
        5. A.2.5. Partitioning and Sorting Algorithms
        6. A.2.6. General Reordering Operations
        7. A.2.7. Permutation Algorithms
        8. A.2.8. Set Algorithms for Sorted Sequences
        9. A.2.9. Minimum and Maximum Values
        10. A.2.10. Numeric Algorithms
      4. A.3. Random Numbers
        1. A.3.1. Random Number Distributions
        2. A.3.2 Random Number Engines
    13. Index
    14. Add Pages

    Product information

    • Title: C++ Primer, Fifth Edition
    • Author(s):
    • Release date: August 2012
    • Publisher(s): Addison-Wesley Professional
    • ISBN: 9780133053043