class C{
friend class F;
private:
fct1(){}
fct2(){}
fct3(){}
public:
fct_for_everyone(){}
};
class F{
};
F is a friend of C, so it has access to fct1,fct2,fct3.
But in real life, friendship has limits! You don't want to reveal everything! So is there a way in C++ to limit the frienships to specific data/functions?
For example, could F be granted access only to fc1 and fct2 but not to fct3.
Here is a way that seems to work:
class C{
protected:
fct1(){}
fct2(){}
private:
fct3(){}
public:
fct_for_everyone(){}
};
class R:private C{
friend F;
}
class F{
};
Here F has access to only fct1 and fct2.
But this is somewhat clumsy and limited. You could not have another friend F2 with other access rights at the same time.
Does anyone has a brilliant (and simple!) way to selectively control access by giving different rights to different friends?