Wrong MQL syntax?

 

I defined a generic interface and I want to use it in another class. I can't figure out what is wrong with this code:

#property strict

template <typename T> interface IGenericHandler {
    bool Handle(T &item);
};

#define DOES_NOT_WORK

class GenericHandler {
    public:
#ifdef DOES_NOT_WORK   
        template <typename T> bool Handle(T &val, IGenericHandler<T> *handler);
#else   
        template <typename T> bool Handle(T &val, IGenericHandler<T> *handler) { return false; }
#endif        
};

#ifdef DOES_NOT_WORK
template <typename T> bool GenericHandler::Handle(T &val, IGenericHandler<T> *handler) { return false; }
#endif

If DOES_NOT_WORK is not defined then everything works. But when DOES_NOT_WORK is defined then the compiler says:

'Handle' - member function already defined with different parameters

 Why?

 
What part of "different parameters" is unclear? The interface takes one parameter, the class takes two.
 
Dan Marinescu:

I defined a generic interface and I want to use it in another class. I can't figure out what is wrong with this code:

If DOES_NOT_WORK is not defined then everything works. But when DOES_NOT_WORK is defined then the compiler says:

 Why?

Interface class does not have definition ("implementation") part, only declaration.

        template <typename T> bool Handle(T &val, IGenericHandler<T> *handler);

only function/method declaration, no function body / implementation / definition.

This here is wrong, because it has method's definition:

        template <typename T> bool Handle(T &val, IGenericHandler<T> *handler) { return false; }


please refer to 
https://www.mql5.com/en/docs/basis/types/classes#interface

 In fact, an interface is a class that cannot contain any members, and may not have a constructor and/or a destructor. All methods declared in an interface are purely virtual, even without an explicit definition.

 
Dan Marinescu:

I defined a generic interface and I want to use it in another class. I can't figure out what is wrong with this code:

If DOES_NOT_WORK is not defined then everything works. But when DOES_NOT_WORK is defined then the compiler says:

 Why?

Compiler bug. Reported.
 

Thank you @Alain Verleyen! I was hoping it was a compiler bug. However, given I'm just starting with MQL I could not make such a claim.

 
Dan Marinescu:

Thank you @Alain Verleyen! I was hoping it was a compiler bug. However, given I'm just starting with MQL I could not make such a claim.

Fixed in beta 2460.
 
I can confirm it works in 2460, but it stopped working in 2470.
 
Dan Marinescu:
I can confirm it works in 2460, but it stopped working in 2470.
You are right.
 
Alain Verleyen #:
You are right.

hi Alain, it seems it's still happening to the latest build as today (build 3559). anywhere in the website that we can track the bug status? 

thanks in advance!!

 
edw lab #:

hi Alain, it seems it's still happening to the latest build as today (build 3559). anywhere in the website that we can track the bug status? 

thanks in advance!!

Nope, only on the forum.

Are you sure your issue is the same as reported here ?

Reason: