If you want to make the class public to only some other class of your application, but not to the complete application, you should declare that other class a friend , e.g.: class SomeOtherClass; class MyClass { friend SomeOtherClass; public: MyClass(); ~MyClass(); int getValue() const; private: void setValue(int i); };