I have an array of base classes, the items thereof contain a child class. The problem is that when I try to access the child class in the array I get the error no operator "[]" matches these operands when I try to do:
shared_ptr<P>& tmpP= (*arrayOfC)[(int)x][(int)y];
I am trying to access the child class. If I do:
arrayOfC[(int)x][(int)y]
then i can access the base class which is not what I am after. I have tried using dynamic_cast to no avail.
The array is
shared_ptr<C> arrayOfC[800][600];
This is declared in another header file and does use forward declaration as well. This is how its being saved:
shared_ptr<P> childClassP= make_shared<P>(z, x, y);
arrayOfC[(int)x][(int)y] = std::move(childClassP);