DeltaElectronics:
Hello to everybody,
I tried to execute this simple example about polymorphism (https://www.mql5.com/en/docs/basis/oop/polymorphism), copying and pasting the code in my MetaEditor; but when I tried to execute it does not work because it alwasy call the method GetARea() of CShape base class instead of that of the derived ones...
I modified the code, in order the base area method alerts the string "pippo" and, as you can see from the screenshot attached, it is that it Always happens, instead of calling the GetArea methods of the corresponding derived classes.
Enclosed is the code I excuted
class CShape { protected: int m_type; // tipo de figura int m_xpos; // X - coordenada del punto de enlace int m_ypos; // Y - coordenada del punto de enlace public: void CShape(){m_type=0;}; // constructor, el tipo es igual a cero int GetType(){return(m_type);};// devuelve el tipo de figura virtual //double GetArea(){Alert("pippo");return (0); } // devuelve la superficie de figura virtual double GetArea(){Alert("pippo");return (0); } };
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
Hello to everybody,
I tried to execute this simple example about polymorphism (https://www.mql5.com/en/docs/basis/oop/polymorphism), copying and pasting the code in my MetaEditor; but when I tried to execute it does not work because it alwasy call the method GetARea() of CShape base class instead of that of the derived ones...
I modified the code, in order the base area method alerts the string "pippo" and, as you can see from the screenshot attached, it is that it Always happens, instead of calling the GetArea methods of the corresponding derived classes.
Enclosed is the code I excuted