"Function already defined and has a different type" Problem


I’m having a problem I don’t know how to solve:

I have defined a public function into a class; this is the declaration:

TOM_ORDER_L* TOM_ExtraOps::get_ORDER_LVL_Pressed(double arg1, TOM_ORDER* order_dada);

The implementation header is exactly the same, but I’m having that error message:

'get_ORDER_LVL_Pressed' - function already defined and has different type    TOM_ExtraOps.mqh    62    30

I don’t understand how is it possible that having EXACTLY the same declaration and header in it’s implementation, I’m getting that error; I don’t know how to solve it.

Thanks in advance for any help/tip.

The declaration in the class should be:

class TOM_ExtraOps
    TOM_ORDER_L* get_ORDER_LVL_Pressed(double arg1, TOM_ORDER* order_dada);

and the function body should be:

TOM_ORDER_L* TOM_ExtraOps::get_ORDER_LVL_Pressed(double arg1, TOM_ORDER* order_dada)
  1. I don’t understand how is it possible

Neither can we. We can’t see your broken code. There are no mind readers here and our crystal balls
are cracked.

  1. Per nhews13’s post, you don’t need the variable names in the declaration, only in the function body.
   TOM_ORDER_L* get_ORDER_LVL_Pressed(double, TOM_ORDER*);

nhews13: Arggggg I can’t believe I didn’t realise that. Absolutely right. Thanks!

rborgnol12 -> No, nhews13 is right; I was forgetting to avoid adding the class name before the function name in the declaration EDIT: Since it doesn’t mind when working with other class functions, it seems that minds when working with constructors; I didn’t realised it.

  1. You don’t need to, but it’s best practice to include the variable names so your code is self documenting, something whroeder is constantly harping about

Yes, you are right and I know it. But in this case it is irrelevant. The important thing is that you must not use the scope resolution in the declaration in this case.