I greatly simplified this question since the same problem arises in a simpler case:
#include <iostream> int height; int main() { std::cout << height; // Visual Studio debugger shows this value as -858993460 int height; }
The problem seems to be that the debugger is displaying the wrong value for the variable. The value of the variable is correct, since printing the variable shows the correct global height value, 0.
You are right, the global variable is heightnot obscured until the automatic variable is declared heightin the final statement main().
height
main()
std::cout << height;will use a global variable height.
std::cout << height;
, . height, 0xCCCCCCCC, -858993460 .
0xCCCCCCCC
-858993460
height , , .