I have class A and class B. class A has a bunch of variables with gets/sets, but I only want those sets to be called from class B. The only way I can think of doing this is making the sets protected, and deriving class B from class A. But then class B would end up inheriting a bunch of unnecessary stuff from class A.
Example:
class A {
public:
void setHealth();
int getHealth();
private:
int health;
};
class B {
public:
void someMethod() { classAInstance.setHealth(); } //This should work
private:
A classAInstance;
};
A classAInstance;
classAInstance.setHealth(); //This should not work because its not being called from Class B
I hope I explained my question enough for you to udnerstand what I need. Thanks in advance!