From: Seungbeom Kim on
On 2010-05-19 09:32, Robi-Wan-Kenobi wrote:
> The compiler (VC 2005) complains containerBase<aDerived*> can't be
> converted to containerBase<aBase*>.
> But i can't see a reason why.

Read C++ FAQ Lite, section [21]:
and you'll understand why.

And yes, even though a container<Derived*> is-not-a container<Base*>
and treating the former as the latter would be dangerous, I agree that
a const container<Derived*> should be-a const container<Base*>, and
it would be nice if the language supported that, but it doesn't.

I'm also sure that many people probably have been bitten by the fact
that a function accepting a pointer to Base doesn't accept a pointer
to Derived any more after changing the pointer from raw to "smart".

Seungbeom Kim

[ See for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]

First  |  Prev  | 
Pages: 1 2
Prev: restriction on inheritance
Next: information for find