Errors, bugs, questions - page 246

 
AlexSTAL:

This is a Class method

https://www.mql5.com/ru/docs/standardlibrary/technicalindicators/cindicator

#include<Indicators\Indicator.mqh>

I see. Apparently,denkir didn't declare#include<Indicators\Indicator.mqh>.

But a search of the Reference is still unable to find this function.

 
Urain:

So why does the compiler swear, what is the ambiguity of the call?


apparently int to long or vice versa types are converted, probably you can only by the number of parameters or by types that are not automatically converted reload functions

SZZ: work only with long, int types you pass as parameters will automatically be converted to long.

 
IgorM:

apparently int to long or vice versa types are converted, probably you can only by the number of parameters or by types that are not automatically converted reload functions

SZY: work only with long, int types you pass as parameters will automatically be converted to long.

Same song.

class CA
  {
public:
   void set(long i,long j,long n){Print("перегрузка long");};
   void set(long i,long j,int n){Print("перегрузка int");};
  };

void OnStart()
  {
//---
   CA a;
   int Int=3;
   long Long=4;
   a.set(1,2,Int);
   a.set(1,2,Long);
  }

The point was to make function overloading for all types without exceptions.

And if a type doesn't correspond to i and j code values, it will generate a warning.

 
Urain:

Dear developers, please tell me what ambiguous call to an overloaded function is (this is what the compiler is swearing about):

'set' - ambiguous call to overloaded function



yes, there is an error, we will fix it after the build release

for now you can use

class CA
  {
public:
   void set(int i,int j,long n){Print("перегрузка long");};
   void set(int i,int j,int n){Print("перегрузка int");};
  };

void OnStart()
  {
//---
   CA a;
   int Int=3;
   long Long=4;
   a.set((int)1,(int)2,Int);
   a.set((int)1,(int)2,Long);
  }
 
Urain:

There is no problem not only with overloading int and long, overload any type the problem will be the same.

It's just the compiler handles an explicit parameter setting in a different way.

Sorry, I have not run MT5 for two weeks, because I see so many angry posts after the last three updates that I do not even want to find out if the compiler is not working or maybe I have the wrong build, which you have

like this:

class CA
  {
public:
   void set(int i,int j,long n){Print("перегрузка long");};
   void set(int i,int j,double x){Print("перегрузка double");};
  };
  
void OnStart()
  {
//---
   CA a;
   int Int=3;
   double doubl=4;
   a.set(1,2,Int);
   a.set(1,2,doubl);
  }

it works, build 362.

 
mql5:

Yes, it's a bug, we'll fix it after the build is released

In the meantime, you can use this

a.set((int)1,(int)2,Long);

Thank you. We'll keep that in mind.
 
Yedelkin:

I see. Apparently,denkir did not declare#include<Indicators\Indicator.mqh>.

But a search of the Reference does not find this function anyway.

This is not enough!

This is a method of an external class!!!

 
AlexSTAL:

That's not enough!

This is an external class method!!!

Well, I'm no expert here, I prefer to write everything by hand. Could you please telldenkir what to do, step by step.
 

Probably need to add such a thing:

#include <Arrays\Array.mqh>
#include <Arrays\ArrayObj.mqh>

But I don't need an object of the mentioned classes. What I need is a simple function for the base type string I described.

 
denkir:

Probably need to add such a thing:

But I don't need an object of the mentioned classes. And I need a simple function for base type string, which I have described.

But to get to the class methods, you have to declare the corresponding class, in our case it's the CIndicator class(MQL5 Reference / Standard Library / Classes for working with indicators / Basic classes / CIndicator). Isn't it so?