Simplifed example of my problem :
I have an abstract class A
. I have two abstract classes B
and C
inheriting from A
. And I have a lot of final classes inheriting from B
or C
:
class A;
class B : public A;
class C : public A;
class B1 : public B;
class B2 : public B;
class C1 : public C;
class C2 : public C;
I implement an algorithm recieving a pointer of A
having to know if the type comes from B
or C
to work properly :
void algorithm(boost::shared_ptr<const A> a)
{
if(*a is a B instance)
// do something
else if(*a is a C instance)
// do something other
}
How can I check that simply without C++11 ?
I know how to check the final type with typeid(*a) == typeid(C1)
, but I don't know how to check a parent type...