c+中数组内部的数组+;类似于python中列表内部的列表 考虑这些可能性: auto test = { { 1, 2, 3 }, { 4, 5, 6 } };

c+中数组内部的数组+;类似于python中列表内部的列表 考虑这些可能性: auto test = { { 1, 2, 3 }, { 4, 5, 6 } };,python,c++,arrays,list,Python,C++,Arrays,List,测试=[[1,2,3],[4,5,6]] #包括 使用名称空间std; 向量测试={1,2,3},{4,5,6}; 当然,你会注意到还有更多的打字。这是因为C++要求你对你正在使用的容器的实际属性更加明确。这是因为C++正在努力确保你做你想做的事情。 < P>考虑这些可能性: auto test = { { 1, 2, 3 }, { 4, 5, 6 } }; 这会将测试创建为包含两个std::initializer\u list实例的std::initializer\u list std::

测试=[[1,2,3],[4,5,6]]

#包括
使用名称空间std;
向量测试={1,2,3},{4,5,6};

当然,你会注意到还有更多的打字。这是因为C++要求你对你正在使用的容器的实际属性更加明确。这是因为C++正在努力确保你做你想做的事情。

< P>考虑这些可能性:

auto test = { { 1, 2, 3 }, { 4, 5, 6 } };
这会将测试创建为包含两个
std::initializer\u list
实例的
std::initializer\u list

std::vector<std::vector<int>> test{ { 1, 2, 3 }, { 4, 5, 6 } };
std::向量测试{{1,2,3},{4,5,6};
创建向量的向量

std::vector<std::array<int, 3>> test{ { 1, 2, 3 }, { 4, 5, 6 } };
std::向量测试{{1,2,3},{4,5,6};
创建固定大小数组的向量

std::array<std::array<int, 3>, 2> test{ { 1, 2, 3 }, { 4, 5, 6 } };
std::数组测试{{1,2,3},{4,5,6};

创建一个固定大小的数组(大小为2),其中包含两个固定大小的数组,每个数组的大小为3。

可能会对您有所帮助。这取决于您希望它与列表的相似程度。
std::array<std::array<int, 3>, 2> test{ { 1, 2, 3 }, { 4, 5, 6 } };