【发布时间】:2012-04-03 10:16:25
【问题描述】:
我正在开发一个游戏库,我可以在其中添加或删除我的游戏。 到目前为止,我只是列出了 3 款标准游戏,但当我试图对其进行测试时。它给了我一个错误。
我正在尝试对我的向量进行迭代,但由于某种原因它不起作用。我找不到那个原因。
这是我的代码:
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main()
{
vector<int>::const_iterator iter;
vector<string> games;
games.push_back("Crysis 2");
games.push_back("God of War 3");
games.push_back("FIFA 12");
cout <<"Welcome to your Games Library.\n";
cout <<"These are your games:\n";
for (iter = games.begin(); iter != games.end(); ++iter)
{
cout <<*iter <<endl;
}
return 0;
}
【问题讨论】:
-
也许您应该说出实际错误是什么,而不是让人们猜测。很好,你包含了完整的代码。
标签: c++ visual-studio-2010 vector iteration