Download MetaTrader 5

default settings of structs

To add comments, please log in or register
Carl Schreiber
Carl Schreiber 2015.08.25 20:06 


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

#property copyright "Copyright 2014, MetaQuotes Software Corp."
#property link      ""
#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);

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.


Ex Ovo Omnia
Ex Ovo Omnia 2015.08.25 20:28  
Structures are not initialized, only allocated. If you need implicit initialization, add the default constructor.
To add comments, please log in or register