What a title, suppose I have a map like this:
std::map<int, int> m;
and if I write the following
cout<<m[4];
- What will be the result (0, uninitialized, compiler specific)?
- Does the same applies for pointers (i.e. std::map)?
EDIT:
To clarify, in this question I am seeking for standard behavior.
Thanks in advance,
Cem
The value will be what the default constructor for the type creates, because new spots are filled using
T(). Forint, this is0. You can see this for yourself:Initializing a type like with empty parentheses like this is called value initialization (see ildjarn’s comment below).