Both programs works. The difference is that in the second code rect and rectb are global variables and in the first code they are local variables in main().
If they are global in first case, so as uninitialised, they are put into bss memory, then when they get initialised, they are in data memory?
What happens with their & and values in any case?
I'm not sure about the exact implementation details but the C++ standard guarantees that in the second code the memory of rect and rectb are zero initialized.