Check if an object is subtype of a base object

 

Can it somehow be done in MQL5 ?

If I have a pointer of a base class, how can I know if it is of type of the subclass? 

 
Amir Yacoby:

Can it somehow be done in MQL5 ?

If I have a pointer of a base class, how can I know if it is of type of the subclass? 

What to do ?
 
Alain Verleyen:
What to do ?

class A : CObject
{
};

class B : A
 {
 };

bool IsInstance(CObject *obj)
 {
   return(obj.IsInstanceOf(A));
 }

 
Amir Yacoby #:

class A : CObject
{
};

class B : A
 {
 };

bool IsInstance(CObject *obj)
 {
   return(obj.IsInstanceOf(A));
 }

bool IsInstance(CObject *obj)
 {
   return CheckPointer(dynamic_cast<A*>(obj)) != POINTER_INVALID;
 }
 
Dynamic_cast is available since: New MetaTrader 5 build 1395 - Page 17 #166 (2016)