我知道如何像这样初始化一维向量
int myints[] = {16,2,77,29};
std::vector<int> fifth(myints, myints + sizeof(myints) / sizeof(int));
假设我有二维数据。
float yy[][2] = {{20.0, 20.0}, {80.0, 80.0}, {20.0, 80.0}, {80.0, 20.0}};
如何初始化二维向量?
在当前的 C++(自 2011 年起)中,您可以在构造函数中初始化此类向量:
vector<vector<float>> yy
{
{20.0, 20.0},
{80.0, 80.0},
{20.0, 80.0},
{80.0, 20.0}
};
看到它还活着:http://ideone.com/GJQ5IU http://ideone.com/GJQ5IU.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)