Pimpl Idiom

Download c++ eBook


The pimpl idiom (pointer to implementation, sometimes referred to as opaque pointer or cheshire cat technique), reduces the compilation times of a class by moving all its private data members into a struct defined in the .cpp file.

The class owns a pointer to the implementation. This way, it can be forward declared, so that the header file does not need to #include classes that are used in private member variables.

When using the pimpl idiom, changing a private data member does not require recompiling classes that depend on it.

Related Examples


251 Contributors: 8
Wednesday, November 23, 2016
Licensed under: CC-BY-SA

Not affiliated with Stack Overflow
Rip Tutorial: info@zzzprojects.com

Download eBook