Download MetaTrader 5

Check if an object is subtype of a base object

To add comments, please log in or register
Amir Yacoby
1195
Amir Yacoby 2016.06.10 23:09 

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
31090
Alain Verleyen 2016.06.11 11:43  
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
1195
Amir Yacoby 2016.06.11 23:52  
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