Nikolay Kurtov wrote:
>I've derived TWO classes from Fred and my compiler had no problem
letting me.
V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask- Hide
quoted text -
- Show quoted text -
Sorry, it really produces an error.
Who "it"? What error?
Now I really confused and cannot understand why it is possible to
derive.
It's possible to derive from _my_ Fred (that doesn't have 'FredBase'
as virtual base class) because NOTHING prevents you from that.
Isn't it true, that a usual inheritance runs first constructor of the
base class and then of the derived one?
The virtual base class subobject is supposed to be _initialised_ in
the most derived class' constructor. If you derive from [the original]
'Fred', say a class 'Foo', then 'Foo::Foo' is responsible for
initialising the 'FredBase' (even if it happens implicitly), and since
'FredBase's constructor is private, it's not accessible to 'Foo' (or
any other class derived from 'Fred' for that matter). That's why you
cannot derive from 'Fred' given in the FAQ. The inability to initialise
the virtual base class in any derived from 'Fred' class makes 'Fred'
non-derivable.
V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask