On Saturday, 20 April 2013 at 21:36:37 UTC, John Colvin wrote:
On Saturday, 20 April 2013 at 17:42:02 UTC, Namespace wrote:
And no, the equivalent version would use 'A' as return type of
'get', not 'A*'.
Sorry, no.
//C++
A* get(unsigned int id);
//D
A get(unsigned int id);
Those are the equivalent declarations. A reference is, for
these intents and purposes, a pointer and D classes are
reference types. In D, "get" returns a reference to an object,
i.e. a pointer to an object.
C++ does not have polymorphic pointers to pointers to class
objects, for good reason (see my original reply). AFAIK the
same reasons apply to D, hence D has no polymorphic pointers to
references to class objects.
woops, that should be uint in the D declaration not unsinged int.