Why do uninitialized class members have arbitrary values in C++?

C++ just allocates the memory and calls the constructor.
You’re free to initialize all members as you wish.

What actually happens while you’re compiling in debug mode is that the compiler actually does initialize the different members to certain values that would help you understand it’s uninitialized.

204 is 0xCC which is the default (microsoft?) debugger initialization value

A similar question and nice answers here: What happens to a declared, uninitialized variable in C? Does it have a value?

Leave a Comment