how to declare a pure virtual function in MQL5??

 

Hello MetaQuotes,

Just as in the topic - how can I declare a pure virtual function in MQL5? I would like to use this mechanism to create interfaces or implement some design patterns. Normally in C++ I would write:

virtual void Foo() = 0;

But the MQL5 compiler doesn't accept it. Should I just write:

virtual void Foo();

??

 

Try

class CMyClass
  {
public:
                     CMyClass(void) { }
                    ~CMyClass(void) { }

   virtual void      Foo() { }
  };

 
Thanks - however this works only for void. What about other types, e.g. bool or int? I could always try to just return some value, but then it isn't really a pure virtual function.
 
MetaQuotes - any comment on this?
 
Enigma71fx:
MetaQuotes - any comment on this?

What is the problem?

class CMyClass
  {
public:
                     CMyClass(void) { }
                    ~CMyClass(void) { }

   virtual void      Foo()  { }
   virtual bool      Foo1() { return(false); }
   virtual int       Foo2() { return(0); }
  };
 
Enigma71fx:
Thanks - however this works only for void. What about other types, e.g. bool or int? I could always try to just return some value, but then it isn't really a pure virtual function.
There are no pure virtual functions in the MQL5
 
stringo:
There are no pure virtual functions in the MQL5
OK stringo, thanks for confirmation.
 

Old thread, but I don't like to open a new thread for a topic without solution.

Funny that the MQL4 documentation explains pure virtual functions and has samples for pure virtual functions.

 
bucket:

Old thread, but I don't like to open a new thread for a topic without solution.

Funny that the MQL4 documentation explains pure virtual functions and has samples for pure virtual functions.

You have misread then.