I just discovered that I can do this in C++, which compiles just fine (MinGW and VC++):
class A
{
private:
void doSth();
A* foo;
A* bar;
};
void A::doSth()
{
foo->bar;
}
The member field bar
of foo
is private. Why can I access it and should I do so?
In C++, private
means the access is limited to the same class, not to the same object instance.