subclass to base class but not subclass pointer to base class pointer?

John Colvin john.loughran.colvin at gmail.com
Sat Apr 20 08:34:49 PDT 2013


On Saturday, 20 April 2013 at 15:32:20 UTC, Andrej Mitrovic wrote:
> On 4/20/13, Namespace <rswhite4 at googlemail.com> wrote:
>> Why can D implicitly cast from the subclass to the base class,
>> but not implicitly from the subclasse pointer to the base class
>> pointer?
>>
>> This works: http://dpaste.1azy.net/30dd34a0
>> This not: http://dpaste.1azy.net/ffacfd83
>>
>> Makes not much sense for me.
>>
>
> I'd really recommend reading one of the D books before asking 
> so many
> fundamental questions: http://wiki.dlang.org/Books
> And probably the spec too.
>
> Bottom line: D is not C++.

It's not allowed in c++ either. See my original reply.


More information about the Digitalmars-d-learn mailing list