I had declared a Boolean variable bool abc;
in a class and thought that it would be false by default. An if condition in my program, if (abc)
,
Talking about primitive built-in data types (bool, char, wchar_t, short, int, long, float, double, long double), according to C++ standard, only global variables get a default value of zero if they are not explicitly initialized.
For local variables it's not required for the complier to clean up the content of the memory they are assigned to. A local variable -- if not explicitly initialized -- will contain an arbitrary value.