Errors, bugs, questions - page 2755

 

Compiler error. Works fine in older builds.

struct A { };

template<typename T> 
struct B : T { };  // 'A' - unexpected token

struct C : B<A> { };
 

I have such a simple Expert Advisor (see screenshot).

There are Chart objects overlaid on the chart.

Before yesterday's terminal update trading levels were shown on the charts, but now they disappeared.

I have created charts as shown in example in manual. I have not found any chart properties to display trade levels (only basic charts have such property).

Please help.

Screenshots from MetaTrader platform

GBPUSD, M5, 2020.05.25

Forex Club International Limited, MetaTrader 5, Real

GBPUSD, M5, 2020.05.25, Forex Club International Limited, MetaTrader 5, Real


Документация по MQL5: Константы, перечисления и структуры / Константы объектов / Типы объектов / OBJ_CHART
Документация по MQL5: Константы, перечисления и структуры / Константы объектов / Типы объектов / OBJ_CHART
  • www.mql5.com
//| Создает объект "График"                                          |               chart_ID=0,                               sub_window=0,                             x=0,                                      y=0,                                      width=300,                                height=200,               ...
 

Hi. Please help me to understand what is written.

mqlrate rt [2] ;

Am I correct in assuming that this is an array of two structures which automatically received the same structure data?

Just further there is no assignment of data to the array and then the data from the array is used at once.
 
Ivan_Invanov:

Hi. Please help me to understand what is written.

mqlrate rt [2] ;

Am I correct in assuming that this is an array of two structures that automatically received the same data?

Written in MQL5:

MqlRates rt[2]

means: a static array of twoMqlRates structures is declared. After declaration, these structures may store gibberish, so these structures need to be explicitly filled with data.

Документация по MQL5: Константы, перечисления и структуры / Структуры данных / Структура исторических данных
Документация по MQL5: Константы, перечисления и структуры / Структуры данных / Структура исторических данных
  • www.mql5.com
Константы, перечисления и структуры / Структуры данных / Структура исторических данных - справочник по языку алгоритмического/автоматического трейдинга для MetaTrader 5
 
Vladimir Karputov:

Writing in MQL5:

means: a static array of twoMqlRates structures is declared. Once declared, these structures can store gibberish, so these structures need to be explicitly filled with data.

Thank you.
 
Alexey Navoykov:

Compiler error. Works fine in older builds.

Yes there is such a thing, reportedas far back as 2020.03.25, already day by day for 2 months...
(
not fixed by MT5(build 2390)) (new) Compile Error, when using default access modifier when inheriting in template class, when template parameter acts as base class.

 

Another bug:

class A
{
  void operator=(A const&) = delete;
};

class B : public A
{
};

class C : public B
{
};

class D : public C
{
 public:
  void operator=(A const& other) { }
};

void OnStart()
{
  C c;
  D d;
  d = c; // attempting to reference deleted function 'void C::operator=(const C&)'
}

C::operator=, although D::operator= is executed here. To work around the bug, you have to overload the operator for all the base classes in the hierarchy.


p.s. In general, the developers promised to fix incorrect assignment operator behavior long ago, but it is still there. This is an outrage. For instance, the following code compiles without errors although it is assigning something:

#include <Expert\Expert.mqh>

#include <Strings\String.mqh>

void OnStart()
{
  CExpert Expert;
  CString String;
  Expert = String; // Ошибки нет. Типа всё нормально?
}
 
Alexey Navoykov:

One more bug:
1) It complains about C::operator=, although D::operator= is executed here. To avoid the bug, we have to overload the operator for all the base classes in the hierarchy.
2) In general, the developers promised to fix incorrect behavior of the assignment operator long ago but it is still there - it is an outrage. For instance, the following code compiles without errors although it assigns whatever it is:

1) This is most likely not a bug but rather a natural behavior considering the specifics of MQL, namely:
In MQL, methods and fields of the base class are "directly available" from the derived classes.
In essence, the inheritance behavior in MQL is similar to using declaration for each basic field and method in C++.
C++ online:https://onlinegdb.com/rJkckvFsU

class A
{
public:
  void operator=(A const&) = delete;
};

class B : public A
{
};

class C : public B
{
public:
    //void operator=(C const& other) { printf("C");}
};

class D : public C
{
public:
#ifdef __cplusplus
  using A::operator=;
  using B::operator=;
  using C::operator=;
#endif
  void operator=(A const& other) { printf("D");}
};

void OnStart()
{
  C c;
  D d;
  d = c; 
}



Thus, all operator= functions from the base classes are also involved in the operationd = c;
when searching for the appropriate function.
As a result, the optimal signature for an overloaded function call is the default and deleted void operator=(const C&).

 
Sergey Dzyublik:

1) Most likely, it is not a bug, but natural behavior considering peculiarities of MQL, namely:
In MQL, methods and fields of a base class are "directly available" from descendant classes.
In essence, the inheritance behavior in MQL is similar to using declaration for each basic field and method in C++.
C++ online:https://onlinegdb.com/rJkckvFsU


Thus, all operator= functions from the base classes are also involved in the operationd = c;
when searching for the appropriate function.
As a result, the optimal signature for an overloaded function call is the default and remote void operator=(const C&).

You don't have to look for the sacred meaning in an obvious language flaw. I already raised this problem here and Ilyas assured that it will be fixed. But almost 10 months have already passed. (

In essence, the inheritance behavior in MQL is similar to that in C++ using declaration

Yeah, well, if in MQL for example 2 x 2 = 5, you could say that it's the same as in C++ adding an increment operation to the result)

 
Alexey Navoykov:

You don't have to look for sacred meaning in an obvious flaw in the language.

It was explained to you how and why it works, if it's difficult for you - fortunately I can't help...
It's not a sacred meaning, but a common approach in order to lower the user input level, so that they can access fields and methods of the base class without using "this.", and also in cases of overloading-a base class function.