You'll do something like this for your base class:
class Enemy
{
public:
// object unique identifier
unsigned int mId;
public:
Enemy(unsigned int aId)
: mId(aId)
{
// common enemy initialization
}
virtual ~Enemy()
{
// common enemy cleanup
}
virtual void Update(void)
{
// common enemy update
}
}
Then, for a specific enemy that does something interesting:
class Enemy1 : public Enemy
{
public:
Enemy1(unsigned int aId)
: Enemy(aId)
{
// enemy 1 specific initialization
}
virtual ~Enemy1()
{
// enemy 1 specific cleanup
}
virtual void Update(void)
{
// enemy 1 update
// also do common update
Enemy::Update();
}
}
You would then maintain a list (or array) of pointers to Enemy, like this:
Enemy *enemyarray[64];
unsigned int enemycount = 0;
Creating an specific enemy works like this:
Enemy *enemy = new Enemy1(id);
enemyarray[enemycount++] = enemy;
Even though the enemy is really an instance of Enemy1, the main loop can treat it as if it were an instance of Enemy.
for (unsigned int i = 0; i < enemycount; ++i)
{
enemy->Update();
}