M
Michael H Lees
Is there any possible way to determine if a class A inherits from class
B at run-time.
So if I have an Abstract Base Class called Grandparent, then a class
which inherits from GrandParent called Parent and finally a class which
inherits from Parent called Child. Something like...
class GrandParent{
public:
virtual bool IsYoung(){return false;}
//...
};
class Parent : public GrandParent{
public:
// ...
};
class Child : public Parent{
public:
bool IsYoung(){return true;}
//...
};
GrandParent *gp_ptr;
Child c;
gp_ptr=&c;
is there anyway to determine that gp_ptr is now pointing to something
which inherits from Parent? Do I just attempt to cast the gp_ptr to a
Parent?
Thanks
B at run-time.
So if I have an Abstract Base Class called Grandparent, then a class
which inherits from GrandParent called Parent and finally a class which
inherits from Parent called Child. Something like...
class GrandParent{
public:
virtual bool IsYoung(){return false;}
//...
};
class Parent : public GrandParent{
public:
// ...
};
class Child : public Parent{
public:
bool IsYoung(){return true;}
//...
};
GrandParent *gp_ptr;
Child c;
gp_ptr=&c;
is there anyway to determine that gp_ptr is now pointing to something
which inherits from Parent? Do I just attempt to cast the gp_ptr to a
Parent?
Thanks