If I have a base class, with only virtual methods and 2 derived classes from the base class, with those virtual methods implemented.
How do I:
// causes C2259
BaseClass* base = new BaseClass[2];
BaseClass[0] = new FirstDerivedClass;
BaseClass[1] = new SecondDerivedClass;
or:
// causes "base is being used without being initialized"
BaseClass* base;
// causes CC59 again
BaseClass* base = new BaseClass;
base[0] = FirstDerivedClass();
base[1] = SecondDerivedClass();
(or something similar)
...so that I can access the BaseClass
s methods through the DerivedClass
,
but by pointer and the pointer is an array of DerivedClass
s?