The C++ Programming Language, 4th Edition

Book description

The new C++11 standard allows programmers to express ideas more clearly, simply, and directly, and to write faster, more efficient code. Bjarne Stroustrup, the designer and original implementer of C++, has reorganized, extended, and completely rewritten his definitive reference and tutorial for programmers who want to use C++ most effectively.

The C++ Programming Language, Fourth Edition, delivers meticulous, richly explained, and integrated coverage of the entire language—its facilities, abstraction mechanisms, standard libraries, and key design techniques. Throughout, Stroustrup presents concise, “pure C++11” examples, which have been carefully crafted to clarify both usage and program design. To promote deeper understanding, the author provides extensive cross-references, both within the book and to the ISO standard.

New C++11 coverage includes

  • Support for concurrency

  • Regular expressions, resource management pointers, random numbers, and improved containers

  • General and uniform initialization, simplified for-statements, move semantics, and Unicode support

  • Lambdas, general constant expressions, control over class defaults, variadic templates, template aliases, and user-defined literals

  • Compatibility issues

Topics addressed in this comprehensive book include

  • Basic facilities: type, object, scope, storage, computation fundamentals, and more

  • Modularity, as supported by namespaces, source files, and exception handling

  • C++ abstraction, including classes, class hierarchies, and templates in support of a synthesis of traditional programming, object-oriented programming, and generic programming

  • Standard Library: containers, algorithms, iterators, utilities, strings, stream I/O, locales, numerics, and more

  • The C++ basic memory model, in depth

This fourth edition makes C++11 thoroughly accessible to programmers moving from C++98 or other languages, while introducing insights and techniques that even cutting-edge C++11 programmers will find indispensable.

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

..

Table of contents

  1. Cover Page
  2. About This E-Book
  3. Title Page
  4. Copyright Page
  5. Contents
  6. Preface
    1. Acknowledgments
  7. Preface to the Third Edition
    1. Acknowledgments
  8. Preface to the Second Edition
    1. Acknowledgments
  9. Preface to the First Edition
    1. Acknowledgments
  10. Part I: Introduction
    1. 1. Notes to the Reader
      1. 1.1. The Structure of This Book
      2. 1.2. The Design of C++
      3. 1.3. Learning C++
      4. 1.4. History
      5. 1.5. Advice
      6. 1.6. References
    2. 2. A Tour of C++: The Basics
      1. 2.1. Introduction
      2. 2.2. The Basics
      3. 2.3. User-Defined Types
      4. 2.4. Modularity
      5. 2.5. Postscript
      6. 2.6. Advice
    3. 3. A Tour of C++: Abstraction Mechanisms
      1. 3.1. Introduction
      2. 3.2. Classes
      3. 3.3. Copy and Move
      4. 3.4. Templates
      5. 3.5. Advice
    4. 4. A Tour of C++: Containers and Algorithms
      1. 4.1. Libraries
      2. 4.2. Strings
      3. 4.3. Stream I/O
      4. 4.4. Containers
      5. 4.5. Algorithms
      6. 4.6. Advice
    5. 5. A Tour of C++: Concurrency and Utilities
      1. 5.1. Introduction
      2. 5.2. Resource Management
      3. 5.3. Concurrency
      4. 5.4. Small Utility Components
      5. 5.5. Regular Expressions
      6. 5.6. Math
      7. 5.7. Advice
  11. Part II: Basic Facilities
    1. 6. Types and Declarations
      1. 6.1. The ISO C++ Standard
      2. 6.2. Types
      3. 6.3. Declarations
      4. 6.4. Objects and Values
      5. 6.5. Type Aliases
      6. 6.6. Advice
    2. 7. Pointers, Arrays, and References
      1. 7.1. Introduction
      2. 7.2. Pointers
      3. 7.3. Arrays
      4. 7.4. Pointers into Arrays
      5. 7.5. Pointers and const
      6. 7.6. Pointers and Ownership
      7. 7.7. References
      8. 7.8. Advice
    3. 8. Structures, Unions, and Enumerations
      1. 8.1. Introduction
      2. 8.2. Structures
      3. 8.3. Unions
      4. 8.4. Enumerations
      5. 8.5. Advice
    4. 9. Statements
      1. 9.1. Introduction
      2. 9.2. Statement Summary
      3. 9.3. Declarations as Statements
      4. 9.4. Selection Statements
      5. 9.5. Iteration Statements
      6. 9.6. goto Statements
      7. 9.7. Comments and Indentation
      8. 9.8. Advice
    5. 10. Expressions
      1. 10.1. Introduction
      2. 10.2. A Desk Calculator
      3. 10.3. Operator Summary
      4. 10.4. Constant Expressions
      5. 10.5. Implicit Type Conversion
      6. 10.6. Advice
    6. 11. Select Operations
      1. 11.1. Etc. Operators
      2. 11.2. Free Store
      3. 11.3. Lists
      4. 11.4. Lambda Expressions
      5. 11.5. Explicit Type Conversion
      6. 11.6. Advice
    7. 12. Functions
      1. 12.1. Function Declarations
      2. 12.2. Argument Passing
      3. 12.3. Overloaded Functions
      4. 12.4. Pre- and Postconditions
      5. 12.5. Pointer to Function
      6. 12.6. Macros
      7. 12.7. Advice
    8. 13. Exception Handling
      1. 13.1. Error Handling
      2. 13.2. Exception Guarantees
      3. 13.3. Resource Management
      4. 13.4. Enforcing Invariants
      5. 13.5. Throwing and Catching Exceptions
      6. 13.6. A vector Implementation
      7. 13.7. Advice
    9. 14. Namespaces
      1. 14.1. Composition Problems
      2. 14.2. Namespaces
      3. 14.3. Modularization and Interfaces
      4. 14.4. Composition Using Namespaces
      5. 14.5. Advice
    10. 15. Source Files and Programs
      1. 15.1. Separate Compilation
      2. 15.2. Linkage
      3. 15.3. Using Header Files
      4. 15.4. Programs
      5. 15.5. Advice
  12. Part III: Abstraction Mechanisms
    1. 16. Classes
      1. 16.1. Introduction
      2. 16.2. Class Basics
      3. 16.3. Concrete Classes
      4. 16.4. Advice
    2. 17. Construction, Cleanup, Copy, and Move
      1. 17.1. Introduction
      2. 17.2. Constructors and Destructors
      3. 17.3. Class Object Initialization
      4. 17.4. Member and Base Initialization
      5. 17.5. Copy and Move
      6. 17.6. Generating Default Operations
      7. 17.7. Advice
    3. 18. Operator Overloading
      1. 18.1. Introduction
      2. 18.2. Operator Functions
      3. 18.3. A Complex Number Type
      4. 18.4. Type Conversion
      5. 18.5. Advice
    4. 19. Special Operators
      1. 19.1. Introduction
      2. 19.2. Special Operators
      3. 19.3. A String Class
      4. 19.4. Friends
      5. 19.5. Advice
    5. 20. Derived Classes
      1. 20.1. Introduction
      2. 20.2. Derived Classes
      3. 20.3. Class Hierarchies
      4. 20.4. Abstract Classes
      5. 20.5. Access Control
      6. 20.6. Pointers to Members
      7. 20.7. Advice
    6. 21. Class Hierarchies
      1. 21.1. Introduction
      2. 21.2. Design of Class Hierarchies
      3. 21.3. Multiple Inheritance
      4. 21.4. Advice
    7. 22. Run-Time Type Information
      1. 22.1. Introduction
      2. 22.2. Class Hierarchy Navigation
      3. 22.3. Double Dispatch and Visitors
      4. 22.4. Construction and Destruction
      5. 22.5. Type Identification
      6. 22.6. Uses and Misuses of RTTI
      7. 22.7. Advice
    8. 23. Templates
      1. 23.1. Introduction and Overview
      2. 23.2. A Simple String Template
      3. 23.3. Type Checking
      4. 23.4. Class Template Members
      5. 23.5. Function Templates
      6. 23.6. Template Aliases
      7. 23.7. Source Code Organization
      8. 23.8. Advice
    9. 24. Generic Programming
      1. 24.1. Introduction
      2. 24.2. Algorithms and Lifting
      3. 24.3. Concepts
      4. 24.4. Making Concepts Concrete
      5. 24.5. Advice
    10. 25. Specialization
      1. 25.1. Introduction
      2. 25.2. Template Parameters and Arguments
      3. 25.3. Specialization
      4. 25.4. Advice
    11. 26. Instantiation
      1. 26.1. Introduction
      2. 26.2. Template Instantiation
      3. 26.3. Name Binding
      4. 26.4. Advice
    12. 27. Templates and Hierarchies
      1. 27.1. Introduction
      2. 27.2. Parameterization and Hierarchy
      3. 27.3. Hierarchies of Class Templates
      4. 27.4. Template Parameters as Base Classes
      5. 27.5. Advice
    13. 28. Metaprogramming
      1. 28.1. Introduction
      2. 28.2. Type Functions
      3. 28.3. Control Structures
      4. 28.4. Conditional Definition: Enable_if
      5. 28.5. A Compile-Time List: Tuple
      6. 28.6. Variadic Templates
      7. 28.7. SI Units Example
      8. 28.8. Advice
    14. 29. A Matrix Design
      1. 29.1. Introduction
      2. 29.2. A Matrix Template
      3. 29.3. Matrix Arithmetic Operations
      4. 29.4. Matrix Implementation
      5. 29.5. Solving Linear Equations
      6. 29.6. Advice
  13. Part IV: The Standard Library
    1. 30. Standard-Library Overview
      1. 30.1. Introduction
      2. 30.2. Headers
      3. 30.3. Language Support
      4. 30.4. Error Handling
      5. 30.5. Advice
    2. 31. STL Containers
      1. 31.1. Introduction
      2. 31.2. Container Overview
      3. 31.3. Operations Overview
      4. 31.4. Containers
      5. 31.5. Container Adaptors
      6. 31.6. Advice
    3. 32. STL Algorithms
      1. 32.1. Introduction
      2. 32.2. Algorithms
      3. 32.3. Policy Arguments
      4. 32.4. Nonmodifying Sequence Algorithms
      5. 32.5. Modifying Sequence Algorithms
      6. 32.6. Sorting and Searching
      7. 32.7. Min and Max
      8. 32.8. Advice
    4. 33. STL Iterators
      1. 33.1. Introduction
      2. 33.2. Iterator Adaptors
      3. 33.3. Range Access Functions
      4. 33.4. Function Objects
      5. 33.5. Function Adaptors
      6. 33.6. Advice
    5. 34. Memory and Resources
      1. 34.1. Introduction
      2. 34.2. “Almost Containers”
      3. 34.3. Resource Management Pointers
      4. 34.4. Allocators
      5. 34.5. The Garbage Collection Interface
      6. 34.6. Uninitialized Memory
      7. 34.7. Advice
    6. 35. Utilities
      1. 35.1. Introduction
      2. 35.2. Time
      3. 35.3. Compile-Time Rational Arithmetic
      4. 35.4. Type Functions
      5. 35.5. Minor Utilities
      6. 35.6. Advice
    7. 36. Strings
      1. 36.1. Introduction
      2. 36.2. Character Classification
      3. 36.3. Strings
      4. 36.4. Advice
    8. 37. Regular Expressions
      1. 37.1. Regular Expressions
      2. 37.2. regex
      3. 37.3. Regular Expression Functions
      4. 37.4. Regular Expression Iterators
      5. 37.5. regex_traits
      6. 37.6. Advice
    9. 38. I/O Streams
      1. 38.1. Introduction
      2. 38.2. The I/O Stream Hierarchy
      3. 38.3. Error Handling
      4. 38.4. I/O Operations
      5. 38.5. Stream Iterators
      6. 38.6. Buffering
      7. 38.7. Advice
    10. 39. Locales
      1. 39.1. Handling Cultural Differences
      2. 39.2. Class locale
      3. 39.3. Class facet
      4. 39.4. Standard facets
      5. 39.5. Convenience Interfaces
      6. 39.6. Advice
    11. 40. Numerics
      1. 40.1. Introduction
      2. 40.2. Numerical Limits
      3. 40.3. Standard Mathematical Functions
      4. 40.4. complex Numbers
      5. 40.5. A Numerical Array: valarray
      6. 40.6. Generalized Numerical Algorithms
      7. 40.7. Random Numbers
      8. 40.8. Advice
    12. 41. Concurrency
      1. 41.1. Introduction
      2. 41.2. Memory Model
      3. 41.3. Atomics
      4. 41.4. volatile
      5. 41.5. Advice
    13. 42. Threads and Tasks
      1. 42.1. Introduction
      2. 42.2. Threads
      3. 42.3. Avoiding Data Races
      4. 42.4. Task-Based Concurrency
      5. 42.5. Advice
    14. 43. The C Standard Library
      1. 43.1. Introduction
      2. 43.2. Files
      3. 43.3. The printf() Family
      4. 43.4. C-Style Strings
      5. 43.5. Memory
      6. 43.6. Date and Time
      7. 43.7. Etc.
      8. 43.8. Advice
    15. 44. Compatibility
      1. 44.1. Introduction
      2. 44.2. C++11 Extensions
      3. 44.3. C/C++ Compatibility
      4. 44.4. Advice
  14. Index
  15. Preparation for Programming in the Real World
  16. Code Snippets

Product information

  • Title: The C++ Programming Language, 4th Edition
  • Author(s): Bjarne Stroustrup
  • Release date: May 2013
  • Publisher(s): Addison-Wesley Professional
  • ISBN: 9780133522884