Title
Can a class with a private virtual base class be derived from?
Status
nad
Section
11.8.3 [class.access.base]
Submitter
Jason Merrill

Created on 1998-10-24.00:00:00 last changed 310 months ago

Messages

Date: 2004-09-10.00:00:00
    class Foo { public: Foo() {}  ~Foo() {} };
    class A : virtual private Foo { public: A() {}  ~A() {} };
    class Bar : public A { public: Bar() {}  ~Bar() {} };
~Bar() calls ~Foo(), which is ill-formed due to access violation, right? (Bar's constructor has the same problem since it needs to call Foo's constructor.) There seems to be some disagreement among compilers. Sun, IBM and g++ reject the testcase, EDG and HP accept it. Perhaps this case should be clarified by a note in the draft.

In short, it looks like a class with a virtual private base can't be derived from.

Rationale: This is what was intended.

History
Date User Action Args
1998-10-24 00:00:00admincreate