map default values

后端 未结 4 1075
时光取名叫无心
时光取名叫无心 2021-01-30 19:22
std::map mapy;
++mapy[5];

Is it safe to assume that mapy[5] will always be 1? I mean, will mapy[5] always get

4条回答
  •  失恋的感觉
    2021-01-30 19:58

    Yes, the default value will be the default of that type. If you want another default, you can create a class that behaves like an int but has a different default constructor.

提交回复
热议问题