Pointer to array of base class, populate with derived class

前端 未结 5 377
心在旅途
心在旅途 2020-12-15 09:47

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:

 // ca         


        
5条回答
  •  猫巷女王i
    2020-12-15 10:09

    This was the answer (from Rubby)

    BaseClass* Base[2];
    
    Base[0] = new FirstDerivedClass;
    Base[1] = new SecondDerivedClass;
    

提交回复
热议问题