Skip to Content
Exceptional C++: 47 Engineering Puzzles, Programming Problems, and Solutions
book

Exceptional C++: 47 Engineering Puzzles, Programming Problems, and Solutions

by Herb Sutter
November 1999
Intermediate to advanced
240 pages
5h 22m
English
Addison-Wesley Professional
Content preview from Exceptional C++: 47 Engineering Puzzles, Programming Problems, and Solutions

Chapter 29. Compilation Firewalls

Difficulty: 6

Using the Pimpl Idiom can dramatically reduce code interdependencies and build times. But what should go into a pimpl_ object, and what is the safest way to use it?

In C++, when anything in a class definition changes (even private members), all users of that class must be recompiled. To reduce these dependencies, a common technique is to use an opaque pointer to hide some of the implementation details.

class X 
{
public:
  /* ... public members ... */
protected:
  /* ... protected members? ... */
private:
  /* ... private members? ... */
  struct XImpl;
  XImpl* pimpl_;         // opaque pointer to
                         // forward-declared class
};

The questions for you to answer are:

  1. What should go into XImpl? There are four common disciplines. ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Exceptional C++ Style 40 New Engineering Puzzles, Programming Problems, and Solutions

Exceptional C++ Style 40 New Engineering Puzzles, Programming Problems, and Solutions

Herb Sutter

Publisher Resources

ISBN: 0201615622Purchase book