Sign in to follow this  

[fixed and helped] Making a Game list using vectors and iterators...

Recommended Posts

Hey guys lookin for maybe some hints on a problem I have that I think (although I am not sure) is just an issue of me not knowing the proper command to do it.. So in this book I am going through Beginning C++ Game Programming and for one of the End of the chapter challenges he asks "Write a program using vectors and iterators that displays a list of a person s favorite video gamse. The program should be able to list all games, add a game and remove a game." So I have not figured everything out with how I am going to accomplish this but first I decided just to test and see how to accomplish some things and how they work before I let the user input the changes etc. So I have decided to use a function for adding a game and that was easy enough I just did

string newGame = addGame("Enter a new game: ");

And that did the trick for adding but what I get stuck on is a way for a user to input the name of the game they want to remove and then have the program remove that game from the list. The only command I know is gameList.pop_back(); which doesn't really accomplish what I want. Anyway thanks for your help :) [Edited by - Sria on April 21, 2006 5:50:02 PM]

Share this post

Link to post
Share on other sites
Ok, I atleast figured out how to do it now although I think i may have sort of scurted the issue with a work around. I don't know if that's considered cheating or not, but if you're interested what I did was:

to display i did

int i = 0;
for (listGames = gameList.begin(); listGames != gameList.end(); ++listGames)
cout<< i <<" - "<< *listGames << endl;

int remove = removeGame("Please select the number of the game you would like to remove. - ";
gameList.erase((gameList.begin() + remove) - 1);

So anyway i got that to work.

Thank you jyk for the website, I bookmarked it but to be honest when I was looking around I did find something that might work but don't yet have the knowledge to understand what it was saying and how to correctly implement it.

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this