-
0 votesanswersviews
带有map和struct的初始化列表
我有一个带字符串键和结构值的映射,我不知道为什么我不能使用a list of initializers实例化一个对象: #include <string> #include <map> using namespace std; struct CodeInfo { int _level = 0; bool _reactive; }; typedef ... -
267 votesanswersviews
为什么列表初始化(使用花括号)比替代品更好?
MyClass a1 {a}; // clearer and less error-prone than the other three MyClass a2 = {a}; MyClass a3 = a; MyClass a4(a); Why? 我在SO上找不到答案,所以让我回答一下我自己的问题 .