alright so i'm making this program for an exercise in Beginning C++ Game Programming and i run it because i think it's all fine and it turns out it's not it pops up an error that says this "45 C:\Documents and Settings\Owner\Desktop\w00t c++ projects\Game list.cpp 'class std::vector<std::string, std::allocator<std::string> >' has no member named 'find' " and highlights this line
Code:
if (list.find(game) != string::npos)
i think it might be that vectors can not use the find function because that is what it seems like...not sure though...here is my full code (it might be a tid bit messy)
Code:
// Game List
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main()
{
string choice;
string game;
char quit = 'n';
vector<string> list;
vector<string>::iterator listIter;
cout << "Welcome to the game list program. This program is made so you can";
cout << "\nsort your games. type 'add' to add a game or type 'delete to";
cout << "\ndelete a game or type 'quit' to quit the program.";
while (quit != 'y')
{
cout << "Current list:";
for (listIter = list.begin(); listIter != list.end(); ++listIter)
{
cout << *listIter << endl;
}
cout << "What do you want to do? add, delete, quit: ";
cin >> choice;
if (choice == "add")
{
cout << "Type in the name of the game you want to add ";
cin >> game;
list.push_back(game);
}
else if (choice == "delete")
{
cout << "Type in the name of the game you want to delete ";
cin >> game;
if (list.find(game) != string::npos)
{
list.erase(game);
}
else
{
cout << "I'm sorry, that game is not in the list";
}
}
else if (choice == "quit")
{
cout << "Are you sure? <y/n>: ";
cin >> quit;
}
}
}
thanks, Rubiks14