accessing private members from header file

i have seen many c++ programs, where the private members from a header file are accessed in the source file. why is happening? As to my knowledge a private member cannot be accessed until it is friend function or member.
> until it is friend function or member.
¿is it?
The header file doesn't hide the stuff in the object. All that stuff must be known to the compiler and all units that use the object.

However, by making stuff private you are saying "don't touch" to everything other than that object's methods and friends.


If you really want to hide all implementation details from anyone who doesn't have your full source code, check out the PIMPL idiom.

Hope this helps.
Topic archived. No new replies allowed.