Hiding private data members? (C++)

Jeff Linahan picture Jeff Linahan · Oct 15, 2008 · Viewed 28.5k times · Source

Is there a way to hide private data members of a C++ class away from its users, in the cpp file? I think of the private members as part of the implementation and it seems a little backwards to declare them in the header file.

Answer

Kristopher Johnson picture Kristopher Johnson · Oct 15, 2008

The "pimpl" idiom is how this is generally handled.

See