C++ 多维 std::array
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/17759757/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-27 21:25:29 来源:igfitidea点击:
Multidimensional std::array
提问by LazySloth13
In C++, how do I create a multidimensional std::array
? I've tried this:
在 C++ 中,如何创建多维std::array
?我试过这个:
std::array<std::array<int, 3>, 3> arr = {{5, 8, 2}, {8, 3, 1}, {5, 3, 9}};
But it doesn't work. What am I doing wrong and how do I fix this?
但它不起作用。我做错了什么,我该如何解决?
回答by billz
You need extra brackets, until c++14 proposalkicks in.
您需要额外的括号,直到c++14 提案生效。
std::array<std::array<int, 3>, 3> arr = {{{5, 8, 2}, {8, 3, 1}, {5, 3, 9}}};