我养成了使用直接列表初始化编写代码的习惯,因为它更有效,并且防止隐式缩小非常有用:
int i {0}; string s {""}; char c {'a'}; bool b {false}; auto num {100}; // But this??
但是当谈到自动说明符时,我听说它被认为是坏的或者不喜欢这样写它,为什么呢?
c++ initialization auto c++11 type-deduction
auto ×1
c++ ×1
c++11 ×1
initialization ×1
type-deduction ×1