CGameUnit *MakeUnit(DWORD id)
{
switch (id)
{
case 0:
return new CFlyerUnit;
break;
case 1:
return new CGroundUnit;
break;
// etc...
}
you see where I'm going (right?)...
Here is the catch -> I don't want to have to write a new (or rewrite) MakeUnit function every time I add a class... So how can I make a table of refrences to classes so I can simply do this...
// PSEUDOCODE ON
CGameUnit *MakeUnit(DWORD id)
{
Get Reference Entry from table....
(maybe a table of class pointers? don't know...)
return new "ReferencePointer";
}
// PSEUDOCODE OFF
Any ideas? or if I need to explain better just say so...
ill-lusion.comziggy@ill-lusion.com Edited by - Ziggy5000 on January 14, 2001 8:42:47 AM