REVIEW - Inside the C++ Object Model


Title:

Inside the C++ Object Model

Author:

Stanley B. Lippman

Publisher:

Addison-Wesley Professional (1996)

Pages:

280pp

Reviewer:

Chris Oldwood

Reviewed:

April 2014

Rating:

★★★★☆


Reviewed: November 2012

I managed to pick this book up second hand from Jon Jagger’s book stall at the ACCU conference this year. It’s been on my wish list for a long time as I’ve always had a fondness for ‘under the hood’ style books. The big question though is how well has it aged? Surprisingly well it seems...

Just a week or so ago the age old argument about C++ being bloated and inefficient reared its ugly head again. The answer it now seems is to point the protagonists to this book as Lippman cites this common myth in his preface as one reason for writing it. I agree with him that an understanding of the implementation helps with writing more efficient code from the get go as you know the costs of various language features.

The book is split into 7 chapters and starts with the fundamental Object Model – how an object is represented in memory. He doesn’t just cover what a v-table is, but instead walks through in detail how we got from a C style struct to a C++ polymorphic object, including such trade-offs as where to place the v-table. He makes continuous references to the evolution of Cfront which helps you understand the earlier constraints that drove the language.

Once the model is cemented he goes on to talk about constructors (default & copy), data members and then different types of functions (static, non-static & virtual) in the following 3 chapters. He covers the Named Return Value Optimisation in depth and provides some performance figures to back things up. What is particularly noticeable is the number of pages devoted to dealing with Virtual Base Classes – you’ll begin to understand why developers often shy away from them.

Chapter 5 looks at the semantics (rather than just the mechanics) of constructors and destructors and their effects on the compiler. Chapter 6 covers new & delete and the tricky issues that initialising arrays throw up. Plus he covers temporary objects in fine detail as that provides a common source of folklore it seems.

The final chapter looks at the then ‘new editions’ to the language – Templates, Exception Handling and Runtime Type Identification (RTTI). Given its age this chapter is lighter on content, but the mechanics and lineage are still very useful. I also learnt another thing about name resolution within templates that really surprised me – this alone made purchasing it worth the price.


Book cover image courtesy of Open Library.





Your Privacy

By clicking "Accept Non-Essential Cookies" you agree ACCU can store non-essential cookies on your device and disclose information in accordance with our Privacy Policy and Cookie Policy.

Current Setting: Non-Essential Cookies REJECTED


By clicking "Include Third Party Content" you agree ACCU can forward your IP address to third-party sites (such as YouTube) to enhance the information presented on this site, and that third-party sites may store cookies on your device.

Current Setting: Third Party Content EXCLUDED



Settings can be changed at any time from the Cookie Policy page.