Topic: Indirect access to base class constructor
Author: rfg@netcom.com (Ronald F. Guilmette)
Date: Thu, 30 Sep 1993 07:05:06 GMT Raw View
In article <930930003040_76336.3114_FHA36-1@CompuServe.COM> 76336.3114@CompuServe.COM (Kevin Dean) writes:
>Some time ago I posted the following problem. I got one reply for, one
>against. Please help; I'd like to be able to use the construct below but
>my compiler vendor says I can't, I say I should. Can anyone
>authoritatively tell me one way or another which it should be? Thanks.
>
>--------------------------------
>
>Should the following code be legal?
>
>class A { public: A(); ~A(); };
>class B : private A { public: B(); ~B(); };
>class C : public B {
>A _a; // Works fine if I remove this line.
>public:
>C() {} // Error: A::A() not accessible.
>~C() {} // Error: A::~A() not accessible.
>};
>
>My instinct says yes, because the member _a of class C is not going
>directly up the class tree to get at its constructor. The question, I
>guess, is how the access privileges to a member's methods and members are
>resolved. Should they be resolved as if the member were a global object or
>should they be resolved in the context of the class in which they reside if
>the member's class is a base class?
I believe that you vendor is mistaken, and that the above code is perfectly
valid. (And by the way, two compilers I have here agree with that view,
while two others I have disagree.)
Perhaps you should ask you vendor to justify the answer they gave you via
some citation from the ARM.
Follow-ups to comp.std.c++ please.
--
-- Ronald F. Guilmette ------------------------------------------------------
------ domain address: rfg@netcom.com ---------------------------------------
------ uucp address: ...!uunet!netcom.com!rfg -------------------------------