我不确定为什么会出现错误,因为我在另一个运行良好的程序中有非常相似的代码。这是我第一次在这个论坛上发帖,所以我不确定要包括什么,但这里是我收到错误的代码。
int AddPlayers(vector<Player>& players)
{
string name;
double wins;
double losses;
double draws;
int x = 0;
Player findPlayer("null", 0, 0, 0);
cout << "Name of player you would like to add?" << endl;
cin >> name;
for (x = 0; x < players.size(); x++ )
{
findPlayer = players[x];
findPlayer.getName();
x++;
if (name == findPlayer.getName())
{
cout << "That player is already in the tournament." << endl;
return 1;
}
Player newPlayer = (name, wins, losses, draws);
players.push_back(newPlayer);
}
}