Download MetaTrader 5

Check if an object is subtype of a base object

To add comments, please log in or register
Amir Yacoby
1253
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? 

Alain Verleyen
Moderator
32408
Alain Verleyen  
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 ?
Amir Yacoby
1253
Amir Yacoby  
Alain Verleyen:
What to do ?

class A : CObject
{
};

class B : A
 {
 };

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

To add comments, please log in or register