I would like to know if there is a way to put only protected and public stuff on the header file .h, and all private stuff in the compile unit .cpp
I need this because the library is going to be used by others, and I wouldn’t like to have to copy and edit all .h files to remove private declarations and implementations.
I tried but got the duplicate declaration error
another question is about private static stuff
can I declare them on the header file and implement them on the .cpp unit?
a private variable and a public get method
I tried but couldn’t implement the method on the unit, it only worked with the declaration and implementation on the header
[]s,
Joe
The proper way to deal with this is to implement the pimpl idiom: Create a class or struct for all private data and put a pointer to such an object in the header file, together with a forward declaration. Now nothing of the private data and methods is visible from the header file.