Link to home
Start Free TrialLog in
Avatar of VEngineer
VEngineer

asked on

bool default initialize

Is standard type bool initialized to false by default?  Or is it undefined until a value {true | false} is assigned?
ASKER CERTIFIED SOLUTION
Avatar of rayb
rayb

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of VEngineer
VEngineer

ASKER

There is a special case in arrays...

Arrays defined in the global scope with fundamental base types have their array elements set to zero unless there is explicit initialization.

Arrays defined in a local scope with fundamental base types have their array elements uninitialized unless there is explicit initialization.
Actually that has nothing to do with arrays. The POD (Plain Old Data, like the built in types, but also classes and structures without constructors and virtual functions and with no members with constructors and virtual functions) are always initialized to 0 when global.  This is true regardless of whether or not they are in an array.  When local or dynamically allocated they will be set to random values.