Errors, bugs, questions - page 49

 

Why does the compiler not see the difference between int and colour.

   void              CreateLabel(int x,int y,color COLOR);   
   void              CreateLabel(int x,int y,int n);

I redefine a function, it scolds me (says I'm careful to mix up the pedals).

'CreateLabel' - ambiguous call to overloaded function with the same parameters
If only there were default parameters, but there are no ambiguities, just define the type of the passed parameter and go ahead.
 
Urain:

Why does the compiler not see the difference between int and colour.

I override a function, it swears (says careful to mix up the pedals).

If only there were default parameters, but there are no ambiguities, just define the type of the passed parameter and go.
In this case, the compiler is complaining that you created two functions with the same name, and the passed parameters have nothing to do with it.
 
sergey1294:
In this case, the compiler complains that you have created two functions with the same name, and the parameters you pass have nothing to do with it.

In that case, read what the word "overloading" means.

SZ well as"function overloading".

Документация по MQL5: Основы языка / Функции / Перегрузка функций
Документация по MQL5: Основы языка / Функции / Перегрузка функций
  • www.mql5.com
Основы языка / Функции / Перегрузка функций - Документация по MQL5
 
Urain:

A question to the writing fraternity, not an error or a bug, but a question who can suggest what...

I want to get the name of the pointer inside the class but it doesn't work.

In general, the essence of the matter is that I want string-nameof the graphical object was assigned automatically.

I want to get a string name for it automatically.

When installing graphical object from class method the name should be automatically assigned depending on the cursor.

I don't know how to do it yet, I think we can do it from scratch.


There are two main ways to automatically name an object (with different variations on this theme, when implementing it):

1. Name generation is based on a numbered list

A separate class does the naming for the object, and it maintains the "numerators" (which can be either for all objects or for a specific group of objects).

In this case, the name is formed on the basis of (preferably): object type, name of symbol (currency pair), textual notation of TF and serial number of object (taken from the numerator).

In this case, depending on the implementation, you can track the presence of the object on the chart, and you can not.

2. The name is formed on the basis of date and time of object creation.

The name under this approach can be formed on the basis of: object type, symbol name, text notation TF and key (formed on the basis of date and time).

PS

In the first variant (in my opinion) it would be more reasonable to implement in class and full cycle of object management (creation, modification and deletion)...

 
Urain:

In that case, read what "overloading" means.

ZS Well as well as"function overloading".

I didn't know that was possible.
 
sergey1294:
Didn't know this was possible.

Polymorphism and function overloading are basic OOP principles that should be present in any self-respecting language.

Polymorphism

Polymorphism is a phenomenon when a function (method) with the same name corresponds to different program code (polymorphic code) depending on which class object is used in calling the method. Polymorphism is ensured by changing the implementation of the ancestor class method in the descendant class with mandatory preservation of the method signature. This ensures that the interface of the parent class is preserved unchanged and allows the linkage of a method name in code with different classes - the method with the given name is taken from the object of the class from which the call is made. This mechanism is called dynamic (or late) binding - in contrast to static (early) binding, which is done at compile time.

Function overloading

Overloading of procedures and functions - the ability to use subprograms of the same name: procedures or functions in programming languages.


Example from standard library of trade classes, class CAccountInfo:

double MarginCheck(const string symbol,ENUM_POSITION_TYPE trade_operation,double volume) const;
double MarginCheck(const string symbol,ENUM_ORDER_TYPE trade_operation,double volume) const;
 
ddd06:

I spent a long time talking to the respected MetaQuotes and proving to them that they had a glitch, and they told me that there was no glitch.

However, I stuck to my guns and they advised me to ask the community.

So, we have an indicator and an Expert Advisor that takes values of the indicator.

Start the tester for EURUSD from 01.07.2010 to 02.07.2010 on М1

We look at the log and see that the values of one buffer change, and the other does not.

This lasts for an hour and then the second buffer is alive, but if you look at the values of the indicator it doesn't coincide.

I even tried changing the account and re-pumping the history, but that didn't help.

Here is a link to my terminal in rar 90mbhttp://dl.dropbox.com/u/6290215/MetaTrader%205%201111.rar, everything is set up there

And the indicator with the advisor in the attachment

You have submitted a code with an error. Naturally, it is your code that gives out the wrong information. You have ignored our remarks about correcting the error, each time offering a new code and each time with an error.
 
Urain:

Why does the compiler not see the difference between int and colour.

I override a function, it swears (says careful to mix up the pedals).

OK, there would be default parameters, but there are no ambiguities, just define the type of the passed parameter and go ahead.
There really is a problem - we'll look into it.
 
Urain, thank you for your message. The error has been corrected.
 
stringo:
You have provided the code with an error. Naturally, this is your code that gives wrong information. At the same time, you have ignored our comments on error fixing, each time offering a new code and each time with an error.

However, if you had told me that there should be no synchronisation and we should build it into the code...

Instead you stubbornly said that everything matches.

but TimeToString(time[0],TIME_DATE|TIME_MINUTES)," buf1-",buf1[1]," buf2-",buf2[1]) instead of TimeToString(time[1],TIME_DATE|TIME_MINUTES)," buf1-",buf1[1]," buf2-",buf2[1]);

this is certainly an error, but it did not affect the point.

I'll postpone adding the new indicator to check how wrong I was.

That is, you were saying that everything coincides and you have corrected the Expert Advisor's code. But in fact, nothing coincides and we should fix the code of the indicator (in order to integrate synchronization into it).