I want to write a C++ class, like this:
In MyClass.h:
class CMyClass
{
public:
CMyClass();
int MyFun(int a, int b);
protected:
int m_iData;
BOOL m_bFlag;
}
In MyClass.cpp
CMyClass::CMyClass()
{
// Some initialization codes
}
int CMyClass::MyFun(int a, int b)
{
// Implemenation of MyFun
}
Now I want to let another developer to use CMyClass, but only want him to be able to:
1. Construct a CMyClass object.
2. Call MyFun function.
and PREVENT him to:
1. Know the implementation of the CMyClass object.
2. Know the existance of the member variable m_iData and m_bFlag.
Now I can put MyClass.h and MyClass.cpp in a static library and compile it, then send the compiled static library as well as only the MyClass.h to the developer, but he will still able to know the protected memory variables m_iData and m_bFlag, and based on them, he can guess the implementation of the MyFun. How to prevent this?
Thanks