Hi,
the following code doesn't compile on Gnu g++ (4.2.4)
Any ideas why?
the marked "POINT 1" below, is member function of derived
class. It should have access right to c0.
Topi
*******
class c1a;
class c1b;
class c0
{
friend class c1a;
protected:
int prot;
private:
int priv;
public:
int pub;
void mf0()
{
c0 *k=this;
k->pub;
k->prot;
k->priv;
}
};
class c1a:public c0
{
public:
void mf1(void)
{
c0 *k=this;
k->pub;
k->prot;
k->priv;
}
};
class c1b:public c0
{
public:
void mf1(void)
{
c0 *k=this;
k->pub;
k->prot; // POINT 1. this point doesn't compile.
k->priv; // POINT 2. this is ok not to compile, no friend.
}
};
main()
{
c1a v1a;
v1a.mf1();
v1a.mf0();
c1b v1b;
v1b.mf1();
v1b.mf0();
}