Hello,
I am testing some code. I have a mammal class that has a virtual function Speak. I have 4 derived classes that inherit from the mammal class. The derived classes each have a Speak function.
Howevever, I am using the code below. And one thing I don't understand is this line.
Many thanks for any explanations for this line.
Code://A mammal pointer that points to 4 mammal objects Mammal *animalArray = new Mammal[4]; Mammal *animal; animal = new Dog; animalArray = animal; //Don't understand, shouldn't it be animalArray[0] = animal animalArray->Speak();