Re: Delegation question...
On May 26, 11:00 am, Ian Collins <ian-n...@hotmail.com> wrote:
On May 24, 5:19 pm, Ian Collins <ian-n...@hotmail.com> wrote:
James Kanze wrote:
On May 24, 9:47 am, Ian Collins <ian-n...@hotmail.com> wrote:
I was going to suggest that technique, but decided against it as the =
wanted to delegate members of std::set. I wouldn't recommend derivin=
from a standard container.
Not even privately? I have no problems with private inheritance
from a standard container; private inheritance is part of the
Yes, you're right, I overlooked private inheritance.
Private inheritance is not suggested on standard container
either. Because the standard containers are not designed
for inheritance at all. Just think about the polymorphism
and virtual destruction , then you'll get the conclusion
that inheritance from standard containors will be dangerous.
With public inheritance maybe, but you can't point a base* to
a derived object if derived uses private inheritance.
You can, and in fact, one frequent use of private inheritance
involves doing just that. But you need cooperation from the
derived class to do so: if the derived class doesn't give you
the Base*, you can't get it otherwise. (The "frequent use" is
to derive privately from something like "EventHander": for
normal client code, this is an implementation detail, and they
can't consider the class to be an EventHander. But the class
itself may register itself as an EventHander with some
EventNotifier, who will address the class through an
Private inheritance hides the fact that a derived is a base.
Except in the explicit cases where it wants to behave as a base.
None of which is really a problem when deriving privately from a
standard container, since you, the author of the class, have
total control, and of course, you will not expose the
James Kanze (GABI Software) email:firstname.lastname@example.org
Conseils en informatique orient=E9e objet/
Beratung in objektorientierter Datenverarbeitung
9 place S=E9mard, 78210 St.-Cyr-l'=C9cole, France, +33 (0)1 30 23 00 34