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

Namespace rswhite4 at googlemail.com
Sat Apr 20 10:42:01 PDT 2013


On Saturday, 20 April 2013 at 17:24:33 UTC, John Colvin wrote:
> On Saturday, 20 April 2013 at 16:36:09 UTC, Namespace wrote:
>> It works fine in C++ (of course with -std=c++0x)
>> http://codepad.org/qLIjGGd4
>
> It's been a while since I did any c++ but:
>
> 1) I don't see any pointer to pointer polymorphism in there.
>
> 2) That c++ code is equivalent to the version of your D code 
> that works, not the version that doesn't.

I return a pointer from an instance of B and the compiler cast it 
implicit to A*. Look what is inside of 'bstore' (instances of B) 
and what the type of 'get' is (A*).

And no, the equivalent version would use 'A' as return type of 
'get', not 'A*'.


More information about the Digitalmars-d-learn mailing list