Original Post
I have a class that has a template. The template is of a base class that I have many other classes deriving from. Only thing is in my template, when i call a function Add() it creates a "new" object and returns the pointer to it (in my template i store a vector of MY templated class so when i Add() it it creates a new one, adds it to the vector list and returns a pointer). Is there a way to somehow use reinterpret_cast to have a pointer to my child classes when i Add() it. here's an example and what i have so far
class cEnemy;
class cEnemy1 : public cEnemy;
class cEnemy2 : public cEnemy;
class cEnemy3 : public cEnemy;
class cLevel
{
public:
tMyVector<cEnemy> EnemyList;
...
};
cEnemy1 *newEnemy = EnemyList.Add() // does vector<cEnemy*>.push_back()
// yes they are stored internally as pointers
// only thing is the Add() would return a cEnemy NOT a cEnemy1 or could do:
// cEnemy1 *newEnemy = reinterpret_cast<cEnemy1>(EnemyList.Add());
// to do it correctly?