I'm asking for help, I'm stumped myself. I've written this script to explain.
struct STRUCT
{
int a;
};
class CLASS
{
public:
int a;
};
STRUCT f1()
{
staticint i = 0;
STRUCT Res;
Res.a = i++;
return(Res);
}
CLASS* f2()
{
staticint i = 0;
CLASS* Res = new CLASS;
Res.a = i++;
return(Res);
}
voidOnStart()
{
int i1 = f1().a + f1().a;
int i2 = f2().a + f2().a;
}
There is a structure and there is a similar class. I need, that after i2 calculation, the corresponding class objects will be deleted spontaneously, as it happens with structure objects, when the same i1 calculation is performed. How to do this?
Комбинатор: Wrap it up in a smart pointer, not sure it can be done by mql
The problem itself is caused by the inability to return a complex structure. For example, if in the code above instead of int a; make string a;, then f1() will fail on return. That's why my eyes fell on classes, but there the described trap awaited.
The (0, 3) tested with error "critical runtime error 512 in OnTimer function (sleep function reaches end of test)" at 0:37:20.429 + history synchronization 0:00:43.395
This is normal and absolutely correct. You asked for the internal size (no payload) of a dynamic object.
Use ArraySize for dynamic objects and apply sizeof to static objects only. Sizeof is counted at compile time and is always a constant.
This is normal and absolutely correct.
Use ArraySize for dynamic objects and apply sizeof only to static objects.
Read the documentation all the way through
Вычисления размера происходит на этапе компиляции.
I'm asking for help, I'm stumped myself. I've written this script to explain.
There is a structure and there is a similar class. I need, that after i2 calculation, the corresponding class objects will be deleted spontaneously, as it happens with structure objects, when the same i1 calculation is performed. How to do this?
fxsaber:
How do I do this?
Wrap it up in a smart pointer, not sure it can be done by mql
Generally, you can override the constructor copy and operator=
This won't work for classes, they are supposed to be returned by pointer only, structures can be returned by value.
Generally, you can override the constructor copy and operator=
This won't work for classes, they are supposed to be returned by pointer only, structures can be returned by value.
During optimization of the Expert Advisor I get the following error
The (0, 3) tested with error "critical runtime error 512 in OnTimer function (sleep function reaches end of test)" at 0:37:20.429 + history synchronization 0:00:43.395
Single test passes without errors.
Version of MT5 and MetaEditor is 1571.
During optimization of the Expert Advisor I get the following error
The "critical runtime error 512 in OnTimer function (sleep function reaches end of test)" error at 0:37:20.429 + history synchronization 0:00:43.395
Remove the maximum amount of code from the Expert Advisor, so that the error is reproducible. And publish the remaining code.