Consider the following:
PImpl.hpp
class Impl;
class PImpl
{
Impl* pimpl;
PImpl() : pimpl(new Impl) { }
~PImpl() { delete pimpl; }
vo
In your example, you can change the implementation of data
without having to recompile the clients. This would not be the case without the PImpl intermediary. Likewise, you could change the signature or name of Imlp::DoSomething
(to a point), and the clients wouldn't have to know.
In general, anything that can be declared private
(the default) or protected
in Impl
can be changed without recompiling the clients.