学习使用vector日记

来源:互联网 发布:nba live 知乎 编辑:程序博客网 时间:2024/06/07 20:02
学习使用vector日记
PointsCal CalTable, temp;
vector<PointsCal> AllCalTable;
1 int lenAllCalTable = AllCalTable.size();
for(int i = 0; i <= lenAllCalTable; ++i)
{
temp = AllCalTable.back();
fileout<<"\t"<<temp.id<<"\t"<<temp.rotCor<<endl;
AllCalTable.pop_back();
}
2
int lenAllCalTable = AllCalTable.size();
for(int i = 0; i <= lenAllCalTable; ++i)
{
temp = AllCalTable[i];//temp = AllCalTable.at(i);
fileout<<"\t"<<temp.id<<"\t"<<temp.rotCor<<endl;
}
在VS2010中,使用上述两种写法的时候会出现Debug Assertion Failed。使用下面的写法不会出现。
3 for(vector<PointsCal>::iterator p = AllCalTable.begin();p != AllCalTable.end(); ++p)
{
temp = *p;
fileout<<"\t"<<temp.id<<"\t"<<temp.rotCor<<endl;
}
0 0