I want to make a class A friend class of class B. I want to do this as these interact very much and A needs to change internals of class B (which I dont want to expose using
One approach is through explicit interfaces, because the implementor of an interface can select who they give them to:
class NearlyPrivateInterface {
public:
virtual void setState() = 0;
virtual void setFlags() = 0;
};
class A {
public:
void attach(NearlyPrivateInterface* instanceOfB);
};
class B: private NearlyPrivateInterface {
public:
void attach(A& a) { a.attach(this); }
};