Reputation: 13000
I've always run with the assumption that all primitives I allocate, initially contain either whatever that address contained previously (garbage) or they contain a debug pattern of bits.
However, I read offhand somewhere, that a constructor will zero out any members that "it cannot reach" in the constructor. I wish I remember where I read that, because it's bugging me a lot now.
My question is, is there a circumstance where certain members of an object are initialized to zero on construction?
Upvotes: 2
Views: 3892
Reputation: 452
As Galik stated, only objects will get initialized (with the default constructor). Some compilers initialize primatives, but you would be writing fundamentally incorrect code if you took advantage of this "feature".
Upvotes: 2