QVector<int> temp;
QVector<int> tpem2;
for (int k = 0; k < Number_cont; k++)
{
temp.push_back(k);
}
for (int i = 0; i < temp.size(); i++)
{
tpem2 << temp.at(i);
}
qDebug() << temp << endl;
std::vector<int> temp1;
std::vector<int> temp3(Number_cont);
for (int k = 0; k < Number_cont; k++)
{
temp1.push_back(k);
}
for (int i = 0; i < temp1.size(); i++)
{
temp3[i] = temp1[i];
}
qDebug() << temp1 << endl;

本文详细探讨了C++标准库中的std::vector与Qt库中的QVector的用法,通过实例展示了如何初始化、填充及遍历这两种向量类型。对比了不同场景下它们的性能差异,为开发者提供了实用的编码技巧。
1408

被折叠的 条评论
为什么被折叠?



