我目前有以下代码
class test
{
public:
test(std::vector<std::string> str)
{
}
test()
{
}
const std::multimap<int, std::multimap<int, test>> _var= {
{0x01, {
{
0x0f, {"A", "B", "C", "D"}
}
}
}
};
};
int main()
{
test t;
}
错误:
main.cpp:29:9: error: could not convert '{{1, {{15, {"A", "B", "C", "D"}}}}}' from '<brace-enclosed initializer list>' to 'const std::multimap<int, std::multimap<int, test> >'
};
^
我想知道为什么将{“ A”,“ B”,“ C”,“ D”}传递给std::vector<std::string> str)
失败?关于如何解决此问题的任何建议?
您需要另外一对牙套。采用:
0x0f, {{"A", "B", "C", "D"}}
否则,编译器将尝试test
使用参数构造一个"A", "B", "C", "D"
,就像test{"A", "B", "C", "D"}
,这不起作用。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句