I'm trying to learn how to have an array of derived classes.
The code below shows a simplified version of the problem I am experiencing.
As you can see, in main() I instantiate a base class and a deriveA class object.
If I call their member functions printMe() they print out what I would expect.
However, if in the holder class which creates an array. With the first item in the array being a base class and the second being a deriveA class. Then when I call holder.printArray() it results in both items in the array printing the base class method of printMe().
I'm confused as to why this is happening, but since this is the first time I have ever attempted this and my knowledge of C++ is rusty to say the least. I'm guessing it's something I am doing wrong.
If some kind person could point out the errors in my code I'd appreciate it.
If the function is virtual in the base class it is automatically virtual in the derived classes so it doesn't matter if you use virtual in the derived class or not.