Let\'s say I have 2 classes that I want to be visible (within a given header file) and one class that is their ancestor, which one I want to be visible only to the previousl
Instead of hiding class, I'd recommend diabling making use if it. In example:
class Hidden
{
private:
friend class Exposed;
Hidden() {}
int hidden_x;
};
class Exposed : private Hidden
{
public:
Exposed() : Hidden() {}
void DoStuff() { printf( "%d" , hidden_x ); }
};
So what you can: - create any number of Exposed class instances in your code - call DoStuff() method from these instances
But you cannot: - instantiate Hidden class (private constructor) - operate on Hidden class members directly or via Exposed class (they are private)