Unlike rudimentary types (int, float, ...), STL containers cannot be left uninitialised. If you do not provide them a value, they will be set to whatever is their default value. In the case of std:: array
, the default is to set all of the elements to their default, which would be zero in the case of numerical types for example. A std:: vector
default value is an empty vector (no element), etc.
What gotchas does the last one have? Will m_hello be initialized properly? WHat if {} is removed from m_hello declaration?
This will s simply requesting that the array be initialised to its default value, which would happen wether or not you'd ask. Without the curly brakets, there would be no difference at all.