c++ - Which "value" has an un-init value? -
i've code:
double val1; double val2 = 0.0; if(val1 != val2) { cout << "different: " << val1 << " | " << val2 << endl; }
which enter if-statement
. think val1
doesn't 0.0 default (i.e. null). value so? thought 0.0 default...
local non-static variables not initialized have indeterminate value, , seemingly random.
you should not use uninitialized local variables leads undefined behavior.
Comments
Post a Comment