I understand from the answer to this question that values of global/static uninitialized int will be 0. The answer to this one says that for vectors, the default construc
The default initialization for an int
type is to initialize it to 0.
This is true of most (if not all) primitive types: char
will initialize to (char)0
(or '\0'
if you prefer), float
will initialize to 0.0f
, and any pointer initializes to NULL
. For other types, the parameterless constructor is invoked.
In general, the default initialization should happen pretty much whenever you aren't able to specify a constructor (or choose not to).