You are right, a getClass() method would be usefull.
Besides the explicit typecasting there is undocumented implicit typecasting, too.
Considering it is rather unique feature neither used in C++ nor JAVA, I wonder how stable it is. I mean, if I coded using implicit casting, would I get a surprise with subsequent compiler versions?
The following code compiles, so far.
void OnStart() { B* x = new B(); // compiles OK without explicit typecasting A* a = x.getO(); B* b = x.getO(); C* c = x.getO(); } class O { }; class A: public O { }; class B: public O { public: O* getO() {return new O();} }; class C: public O { };
Besides the explicit typecasting there is undocumented implicit typecasting, too.
Considering it is rather unique feature neither used in C++ nor JAVA, I wonder how stable it is. I mean, if I coded using implicit casting, would I get a surprise with subsequent compiler versions?
The following code compiles, so far.
It compiles but doesn't run, at least in current build (1065/ME1562).
2017.04.13 20:41:42.626 __tests__ EURUSD,M1: incorrect casting of pointers in '__tests__.mq4'
- dynamic_cast
- But you shouldn't care. The base class should have all the capabilities you need. Object-Oriented Programming

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
"You can use the explicit casting to convert the base class pointers to the pointers of a derived class. But you must be fully confident in the admissibility of such a transformation, because otherwise a critical runtime error will occur and the mql5 program will be stopped."
Is there any way to check what kind of object type I am using - for example get the class name ? I wish to be able to do this to see I am casting to the right type of object a base class. For example in java you have the "getClass" method :)