K
karl
I've got a abstract class CBase and two classes CPoly1 and CPoly2 that
inherit from CBase.
Is there a way to find out the classtype (CPoly1 or CPoly2) when
iterating over a list of objects for example.
Something like (CLASSTYPE(b) == CPoly2).
Thanks!
class CBase {
public:
virtual void func() = 0;
};
class CPoly1 : public CBase { };
class CPoly2 : public CBase { };
//method that goes through vector of polymorphic objects
CBase *b;
std::list<CBase*>::iterator it;
for (it=this->liste->begin(); !(it==this->liste->end()); it++) {
b=*it;
if (CLASSTYPE(b) == CPoly2) b->doSomethingSpecial(); // HOW TO
CHECK TYPE?
}
inherit from CBase.
Is there a way to find out the classtype (CPoly1 or CPoly2) when
iterating over a list of objects for example.
Something like (CLASSTYPE(b) == CPoly2).
Thanks!
class CBase {
public:
virtual void func() = 0;
};
class CPoly1 : public CBase { };
class CPoly2 : public CBase { };
//method that goes through vector of polymorphic objects
CBase *b;
std::list<CBase*>::iterator it;
for (it=this->liste->begin(); !(it==this->liste->end()); it++) {
b=*it;
if (CLASSTYPE(b) == CPoly2) b->doSomethingSpecial(); // HOW TO
CHECK TYPE?
}