CheckPointer() does not return a bool. Your Ternary Operator ?: is wrong. Correct and simplify
#define INSTANCE_OF(object, classname) (dynamic_cast<classname *>GetPointer(object) != NULL)
@William Roeder There's a ')' missing after GetPointer.
In case someone's interested. Here's a function to check if an object actually is a pointer:
template<typename T> bool IsPointer(T *p) { return true; } template<typename T> bool IsPointer(T p) { return false; } template<typename T> bool IsPointer(const T &p) { return false; } void *ptr; Print("IsPointer(ptr): ",IsPointer(ptr));
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
I remember looking for this "InstanceOf" function when I just started programming in MQL. I have created a macro some time ago to simulate this function and share it here. Enjoy it.
Usage: