The constructor should always be excecuted, also with ArrayResize. When changing struct to class, it works in both cases, struct works only with first case, not when using ArrayResize()
struct CA
{
public: int intvalue;
public: CA()
{
Print("Constructing CA");
}
voidoperator = (CA & source) { intvalue=source.intvalue; }
voidoperator = (int value) { intvalue=value; }
};
struct S
{
CA a;
};
S s[];
//+------------------------------------------------------------------+//| Expert initialization function |//+------------------------------------------------------------------+intOnInit()
{
//--- This will execute the constructor
CA a=21;
//--- This will skip the constructorArrayResize(s,1);
s[0].a = 21;
//---return(INIT_SUCCEEDED);
}
Hi,
this is a bug, right?
The constructor should always be excecuted, also with ArrayResize. When changing struct to class, it works in both cases, struct works only with first case, not when using ArrayResize()