The canonical form of the pimpl idiom (from Herb Sutter's "Exceptional C++") is as follows:
class X
{
public:
/* ... public members ... */
protected:
/* ... protected members? ... */
private:
/* ... private members? ... */
struct XImpl;
XImpl* pimpl_; // opaque pointer to
// forward-declared class
};
My question is, why is XImpl
declared as a struct instead of a class?
private
for aclass
vs.public
for astruct
seems trivially overkill. – Dyaus