default settings of structs

 

Hi,

does anybody know how the initial values of a struct are set?

#property copyright "Copyright 2014, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
#property strict
//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
struct __test {
   int i;
   bool isFalse;
};
void OnStart()
  {
//---
   __test x;
   Comment("False: ",x.isFalse,"  i: ",x.i);
   Print("False: ",x.isFalse,"  i: ",x.i);
   DebugBreak();
  }

The result I get:

2015.08.25 22:02:49.193 struct_test EURUSD,M5: False: true  i: 259979672

Normally any boolean variable is set to  0 (=false) and integers to 0 too.

On the other hand a boolean variable 'within' a struct will always be set true?

And what does i=259 979 672 mean? The highest integer is 2 147 483 647.

Gooly

 
Structures are not initialized, only allocated. If you need implicit initialization, add the default constructor.
Reason: