>1. Ref [1] in above code, what does private virtual means in terms of
>copies of base class ? What Fred holds ? What FredSon holds ?
Private inheritance is a variation of composition. This:
class Fred : private virtual DummyFredBase {};
Is essentially the same thing as this:
class Fred {
private:
DummyFredBase base;
};
The only real difference is syntax.
>2. Ref [2] in above code, with proposed solution compiler wont throw
>an error at the time of derivation instead it does so while making instance of FredSon[3].
Yes, that's correct.
>the error should be thrown at the time of deriving the class that means at place [2].
Sorry, you can't do that without using some language extension or preprocessor. C++ doesn't support that kind of static check.
Narue
Bad Cop
15,460 posts since Sep 2004
Reputation Points: 6,464
Solved Threads: 1,401