I ran into a problem when adding derived objects into an array of (abstract) base pointers. To simplify what I'm trying to do, here is an example:
Base** baseArray = new Base*[3];
baseArray[0] = new derived1(param,param);
baseArray[1] = new derived2(param,param);
baseArray[2] = new derived3(param,param);
Now, I have yet to get my virtual Print() working to print out the baseArray elements but using the vs2012 debugger I can only see baseArray[0] in baseArray. The other two are just gone.
But I guess my main question is that, should the example above work. If yes, would it be too much to ask of what could have happened. If not, is there a (better) way?
Edit: Thank you all!