Inside the C++ Object Model

Book description

Inside the C++ Object Model focuses on the underlying mechanisms that support object-oriented programming within C++: constructor semantics, temporary generation, support for encapsulation, inheritance, and "the virtuals"--virtual functions and virtual inheritance. This book shows how your understanding the underlying implementation models can help you code more efficiently and with greater confidence. Lippman dispells the misinformation and myths about the overhead and complexity associated with C++, while pointing out areas in which costs and trade offs, sometimes hidden, do exist. He then explains how the various implementation models arose, points out areas in which they are likely to evolve, and why they are what they are. He covers the semantic implications of the C++ object model and how that model affects your programs.


  • Explores the program behavior implicit in the C++ Object Model's support of object-oriented programming.

  • Explains the basic implementation of the object-oriented features and the trade offs implicit in those features.

  • Examines the impact on performance in terms of program transformation.

  • Provides abundant program examples, diagrams, and performance measurements to relate object-oriented concepts to the underlying object model.

  • If you are a C++ programmer who desires a fuller understanding of what is going on "under the hood," then Inside the C++ Object Model is for you!

    Get a value-added service! Try out all the examples from this book at CodeSaw is a free online learning tool that allows you to experiment with live code from your book right in your browser.


    Table of contents

    1. Copyright
      1. Dedication
    2. Preface
      1. What Is the C++ Object Model?
      2. Organization of This Book
      3. The Intended Audience
      4. A Note on Program Examples and Program Execution
      5. Acknowledgments
      6. References
        1. Bibliography
    3. 1. Object Lessons
      1. Layout Costs for Adding Encapsulation
      2. 1.1. The C++ Object Model
        1. A Simple Object Model
        2. A Table-driven Object Model
        3. The C++ Object Model
          1. Adding Inheritance
        4. How the Object Model Effects Programs
      3. 1.2. A Keyword Distinction
        1. Keywords, Schmeewords
        2. The Politically Correct Struct
      4. 1.3. An Object Distinction
        1. The Type of a Pointer
        2. Adding Polymorphism
    4. 2. The Semantics of Constructors
      1. 2.1. Default Constructor Construction
        1. Member Class Object with Default Constructor
        2. Base Class with Default Constructor
        3. Class with a Virtual Function
        4. Class with a Virtual Base Class
        5. Summary
      2. 2.2. Copy Constructor Construction
        1. Default Memberwise Initialization
        2. Bitwise Copy Semantics
        3. Bitwise Copy Semantics—Not!
        4. Resetting the Virtual Table Pointer
        5. Handling the Virtual Base Class Subobject
      3. 2.3. Program Transformation Semantics
        1. Explicit Initialization
        2. Argument Initialization
        3. Return Value Initialization
        4. Optimization at the User Level
        5. Optimization at the Compiler Level
        6. The Copy Constructor: To Have or To Have Not?
        7. Summary
      4. 2.4. Member Initialization List
    5. 3. The Semantics of Data
      1. 3.1. The Binding of a Data Member
      2. 3.2. Data Member Layout
      3. 3.3. Access of a Data Member
        1. Static Data Members
        2. Nonstatic Data Members
      4. 3.4. Inheritance and the Data Member
        1. Inheritance without Polymorphism
        2. Adding Polymorphism
        3. Multiple Inheritance
        4. Virtual Inheritance
      5. 3.5. Object Member Efficiency
      6. 3.6. Pointer to Data Members
        1. Efficiency of Pointers to Members
    6. 4. The Semantics of Function
      1. 4.1. Varieties of Member Invocation
        1. Nonstatic Member Functions
          1. Name Mangling
        2. Virtual Member Functions
        3. Static Member Functions
      2. 4.2. Virtual Member Functions
        1. Virtual Functions under MI
        2. Virtual Functions under Virtual Inheritance
      3. 4.3. Function Efficiency
      4. 4.4. Pointer-to-Member Functions
        1. Supporting Pointer-to-Virtual-Member Functions
        2. Pointer-to-Member Functions under MI
        3. Pointer-to-Member Efficiency
      5. 4.5. Inline Functions
        1. Formal Arguments
        2. Local Variables
    7. 5. Semantics of Construction, Destruction, and Copy
      1. Presence of a Pure Virtual Destructor
      2. Presence of a Virtual Specification
      3. Presence of const within a Virtual Specification
      4. A Reconsidered Class Declaration
      5. 5.1. Object Construction without Inheritance
        1. Abstract Data Type
        2. Preparing for Inheritance
      6. 5.2. Object Construction under Inheritance
        1. Virtual Inheritance
        2. The Semantics of the vptr Initialization
      7. 5.3. Object Copy Semantics
      8. 5.4. Object Efficiency
      9. 5.5. Semantics of Destruction
    8. 6. Runtime Semantics
      1. 6.1. Object Construction and Destruction
        1. Global Objects
        2. Local Static Objects
        3. Arrays of Objects
        4. Default Constructors and Arrays
      2. 6.2. Operators new and delete
        1. The Semantics of new Arrays
        2. The Semantics of Placement Operator new
      3. 6.3. Temporary Objects
        1. A Temporary Myth
    9. 7. On the Cusp of the Object Model
      1. 7.1. Templates
        1. Template Instantiation
        2. Error Reporting within a Template
        3. Name Resolution within a Template
        4. Member Function Instantiation
      2. 7.2. Exception Handling
        1. A Quick Review of Exception Handling
        2. Exception Handling Support
          1. Determine if the Throw Occurred within a try Block
          2. Compare the Type of the Exception against the Type of Each Catch Clause
          3. What Happens When an Actual Object Is Thrown during Program Execution?
      3. 7.3. Runtime Type Identification
        1. Introducing a Type-Safe Downcast
        2. A Type-Safe Dynamic Cast
        3. References Are Not Pointers
        4. Typeid Operator
      4. 7.4. Efficient, but Inflexible?
        1. Dynamic Shared Libraries
        2. Shared Memory

    Product information

    • Title: Inside the C++ Object Model
    • Author(s):
    • Release date: May 1996
    • Publisher(s): Addison-Wesley Professional
    • ISBN: 9780201834543