Errors, bugs, questions - page 2808

 
Error at execution
class A {};
class B : public A {
public:
template<typename T>
                void f( T )  { printf( "%d", 1 ); }
};
class C : public B {
public:
                void f( A* ) { printf( "%d", 2 ); }
};
void OnStart()
{
        C *c;
        B *b;
        c.f( b );
}

The result in MQL: 1

In C++: 2

As far as I remember the original MQL concept was changed long ago and now, like in C++, the base class is called only if there's no suitable function in a derived one. Or maybe they've changed it all again?

 
A100:

In MQL it's fine:

but C++ gives an error in both cases

What could be an error in the second case? There's at most a warning (hint) that a pointer was declared but not used.

 
Please solve the bug observed in all new versions

2020.07.26 10:54:28.285 PKFDC0:30019 genetic pass (94, 1154) tested with error "OnInit returned non-zero code 1" in 0:00:00.110

2020.07.26 10:54:28.289 Tester expert file ....\MQL5\StochasticCCI.ex5 open error [2]

it's not there and shouldn't be.

the error is a network agent after the upgrade, before the upgrade it worked fine, in old versions the optimizer does not give an error in the Expert Advisor, the Expert Advisor was not recompiled

full demolition and reinstallation of Metatrader with deletion of all data had no effect



 
Boris Egorov:
Please solve the bug observed in all new versions

2020.07.26 10:54:28.285 PKFDC0:30019 genetic pass (94, 1154) tested with error "OnInit returned non-zero code 1" in 0:00:00.110

2020.07.26 10:54:28.289 Tester expert file ....\MQL5\StochasticCCI.ex5 open error [2]

it's not there and shouldn't be.

the error is a network agent after the upgrade, before the upgrade it worked fine, in old versions the optimizer does not give an error in the Expert Advisor, the Expert Advisor was not recompiled

full demolition and reinstallation of Metatrader with deletion of all data had no effect



Show the code of your indicator call, please.
 
Mihail Matkovskij:

What could be the error in the second case? There is at most a warning (hint) that the pointer was declared but is not used.

That's because it's not

class B : public A {};
There may be different dialects, so it is worth checking with the Developers in any case
 
MetaQuotes:
Show the code of your indicator call, please.

Note the post, people's advisers have stopped working !!!!!!! https://www.mql5.com/ru/forum/347385/page5#comment_17519416

Новая версия платформы MetaTrader 5 build 2560: Улучшения во встроенной системе обучения
Новая версия платформы MetaTrader 5 build 2560: Улучшения во встроенной системе обучения
  • 2020.07.26
  • www.mql5.com
В пятницу 24 июля 2020 года будет выпущена обновленная версия платформы MetaTrader 5...
 

Forum on trading, automated trading systems and trading strategy testing

Bugs, bugs, questions

A100, 2020.07.26 01:02

I have only one error in MQL:

class A {};
class B : A {};
class C : B {
                void f1( A* ) {}    //(1)нормально
                void f2() { A *a; } //(2)нормально
};

but C++ has an error in both cases


Please explain why there is a problem with this code?

 
fxsaber:

Please explain why there is a problem in this code?

I have no idea! I took this example apart... Changed struct to class -C++ shell threw an error:

error: 'class A A::A' is inaccessible

You can check it yourself.

 

context resolution. the constructor is inaccessible through the ancestor because of private inheritance.

If you explicitly specify context, everything compiles

                void f1( ::A* ) {}    //(1)нормально
                void f2() { ::A *a; } //(2)нормально

_____

don't ask why a constructor is required - I have no idea.

 
@A100, @TheXpert, Thank you.
Reason: