Recently, I discovered something I should have discovered a long time ago - how to hide a class' private members.
All of you should know this (you are experts):
Then I implement the methods in the Implementation class. All makes sence. Pointer sizes depend on the architecture and do not depend on what they point to, that's obvious (how else would void* exist?)Code:class Implementation; //Forward declaration of the implementation class Interface { public: //yodda yodda, public, private, protected methods Implementation* ptr; };
I often want to hide the implementation as far as possible, but I understand that this implementation moves the members into the Heap -- that is obviously a slowdown.
On the other hand, it prevents the user (of the class) from creating additional methods that give him access to the members. But they can always do the same with the pointer can't they? For instance, they can make it point to NULL!
So, when is it useful to do this and when isn't it? Logically, on proprietary/closed-source libraries this is probably used, or are there other methods?
Thanks, Jorl17



LinkBack URL
About LinkBacks
):




