Hello all,
Please consider:
class Base {
public: int pub;
protected: int prot;
private: int priv;
};
class D1 : public Base { };
class D2 : protected Base { };
class D3 : private Base { };
int main()
{
D1 d1; D2 d2; D3 d3;
d1.pub = 0; //fine - public
d1.prot = 0; //error - protected
d1.priv = 0; //error - private
d2.pub = 0; //error - protected
d2.prot = 0; //error - protected? ('inaccessible')
d2.priv = 0; //error - private
d3.pub = 0; //error - private? ('inaccessible')
d3.prot = 0; //error - protected
d3.priv = 0; //error - private
return 0;
}
I would have expected that the error messages for the lines I've tagged with
'inaccessible' to complain about d2.prot being protected and d3.pub being
private, as to my knowledge this is how they would act given their access
specifiers and the types of inheritance used.
However, both MinGW's g++ and VC++ Express 05 use the phrase "inaccessible" and
avoid "protected" and "private" (which are used in all the other erroneous
cases). Does this mean there's some kind of technical middle-ground between
public/protected/private or am I reading in to these error messages too much?! I
suspect the latter, but I just want to make sure.
Thanks for your patience, and happy new year.
Edd
--
Edd Dawson www.nunswithguns.net | "It's sad when someone you know
To email me, cut the crap. | becomes someone you knew."
ed*@nunswithcrapguns.net | - Henry Rollins