E
Ernst Murnleitner
Hello readers,
I want to enumerate all values in an enum, e.g.:
{
enum Family{A=0, B,C, D = 100, E};
BaseItem * p = Factory::Get...// BaseItem is the basis of many other items
// BaseItem has a virtual Function IsA(f) which tests if the item is member
of Family f.
int iNum = 0;
for(Family e = A; e <= E, e++) // but this does not work, of course
if(p->IsA(e))
iNum ++;
cout << "Item is Member of " << iNum << " families" << endl;
}
It seems not to be possible? Is there another elegant solution
Greetings
Ernst
I want to enumerate all values in an enum, e.g.:
{
enum Family{A=0, B,C, D = 100, E};
BaseItem * p = Factory::Get...// BaseItem is the basis of many other items
// BaseItem has a virtual Function IsA(f) which tests if the item is member
of Family f.
int iNum = 0;
for(Family e = A; e <= E, e++) // but this does not work, of course
if(p->IsA(e))
iNum ++;
cout << "Item is Member of " << iNum << " families" << endl;
}
It seems not to be possible? Is there another elegant solution
Greetings
Ernst