Get which derived class an object is if it's stored in an array of its base class
Morimur55 via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Sat Jul 15 07:26:30 PDT 2017
On Saturday, 15 July 2017 at 14:04:17 UTC, Adam D. Ruppe wrote:
> On Saturday, 15 July 2017 at 13:45:40 UTC, Morimur55 wrote:
>> Well I want to cast to the derived type so I can use a method
>> that's defined in the base class, but is overridden in several
>> of the derived types... and calling it without a cast seems to
>> give me the base type functionality, but I'd like the derived
>> type functionality when it's defined.
>
> That means you're doing something wrong. What does your base
> class method look like? Is it a template?
class Base {
private static int idcounter = 0;
int nextid(){ return ++idcounter }
}
class Derrived {
More information about the Digitalmars-d-learn
mailing list