I am developing a games library where I can add or delete my games.
So far I just made a list with 3 games in standard, but when i was trying to test it. It gave me an error.
I am trying to do it with an iteration on my vector, but for some reason it won’t work. And i can’t find that reason.
here’s my code:
#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;
}
the types of you iterator and your vetcor are incompatible.
use:
To make things easier it might be better to typedef your collection type: