Yes, it will be initialized to 0
in accordance with the C ++ standard.
Link:
C ++ 03 Standard:
23.3.1.2 access to the map element [lib.map.access]
T& operator[](const key_type& x);
Returns:(*((insert(make_pair(x, T()))).first)).second.
T()
default - initializes the object. Although the default values ββfor the variables are listed in the section:
C ++ 03 Standard 8.5 / 5:
In default-initialize, an object of type T means:
- if T is a non-POD class type (section 9), the default constructor for T is called (and initialization is poorly formed if T does not have an available default constructor); - if T is an array type, each element is initialized by default;
- , otherwise the object is initialized to zero.
The latter case applies to your code here.
Alok save
source share