| DJLad15 (97) | |||
Here's my program so far:
So the aim of my program is the user can enter their favourite games, and add or remove their games. But I am having a problem with the user entering any further games. If you look at line 25, that's where I'm stuck (I just made it insert Skyrim to see if it would work - and it did) However, I want to make so that the user can enter a game. I've tried cin >> favGames.insert(fav.begein), " ") But that didn't work, and I've tried putting it in a for loop. And I either get an error to with the >> or the . bit.Line 33 is just something I did to see if outputted "6" so I know the vector size has increased - it did. I appreciate any help :D I also thought I might have to use iterators, but I'm still not 100% on them. | |||
|
Last edited on
|
|||
| jlb (77) | |
| To add more than 5 games you will need to increase the size of your vector by either using the push_back(), insert() methods or resize() your vector to a larger size. | |
|
|
|
| fafner (222) | |||
|
If I'm not mistaken, the []-operator for the std::vector class can't be used to actually store elements in the vector. You have to use push_back for that. EDIT: Instead, try
Or something like that :) | |||
|
Last edited on
|
|||
| DJLad15 (97) | |
| Thanks guys, I forget to mention that I did know and try about push_backs(); But I just didn't know how to use them so that it would store elements inputted by the user. | |
|
|
|