What are you doing is creating another vector with the same name as member, shadowing it. All changes are made to the local vector and do not persist.
This actually should give a warning. If you do not have warnings enabled in your IDE, do it. They help greatly. If they are enabled, read them.
Later you will probably want to separate saving another player in database and printing content of database, so you won't have to add another player if you just want to print all players in database.
@Dput You do see, that he had multiple problem with print function, right? Multiple responsibility, taking unnesesary parameters, doing unneeded work. Why not to show how it should be done instead of dirty patching existing code full of bad habits? Especially if it takes almost no work? (I did sugest to replace gotos but did not insist on it because it will truly lead to complete rewrite)
Later you will probably want to separate saving another player in database and printing content of database, so you won't have to add another player if you just want to print all players in database.
int main()
{
string a;
int exit;
string letter;
int i = 1;
int n_l=0, n_r=0, n_e=0;
string line;
string firstname;
string lastname;
string email_;
string age_;
string gender_;
string optionn;
player get_datam;
database savem;
//***the main question***//
thestart:
cout<< "1-Add a player" << endl; // program's question
cout<< "2-list players" << endl;
cout<< "3-play game" << endl;
cout<< "Q-Quit" << endl;
cin >> optionn;
option:
if (optionn== "1") // if the variable equation equals 1
{
goto addplayer ; // going to the option 1 add aplayer
}
elseif (optionn== "2") // going to the option 2 list player
{
goto listplayer ;
}
elseif (optionn== "3") // going to the option 3 playgame
{
goto playgame;
}
elseif (optionn== "q") // exit
{
goto end;
}
else
{
cout <<"Error:Invalid option."<<endl;
goto thestart; //going to the beginning and repeating all the previous steps
}
//*** option one***//
{
addplayer: // lable of goto command
get_datam.get_data();
savem.save(get_datam);//<---SAVE your player!
//***** player information ***//
//*** connect to the class that deal with player's information ***//
get_datam.print();
goto thestart;
}
//**************************//
//****option two***//
//*** list all plyers who has been saved in the text file listplayers ***//
{listplayer:
savem.display();//<---Print your player!
goto thestart;
//**************************//
}
//*** option three ***//
//*** program game ***//
{
playgame:
cout<<i<< ".Enter a letter if Left or Right is greater/equal: L E R" << endl; // program's question
cout<< "Q:Quit" << endl;
cin >> letter;
if (letter=="l"||letter=="L"||letter=="r"||letter=="R"||letter=="e"||letter=="E")
{
cout<< "Answer:"<<letter<< endl;
i = i + 1 ; // changing the number of the question to the next number
if (letter=="l"||letter=="L") //counting how many the letter l has been entered
{
n_l = n_l + 1;
}
elseif (letter=="r"||letter=="R") //counting how many the letter r has been entered
{
n_r = n_r+1 ;
}
else //counting how many the letter e has been entered
{
n_e = n_e + 1 ;
}
goto playgame ; // going to the playgame and repeating all the previous steps
}
elseif (letter=="q"||letter=="Q") // print the result and exit from the program
{
i = i-1 ; // uncounting the the question if the answer is q
cout <<i<<"questions: "<<n_l<<"L "<<n_e<<"E "<<n_r<<"R"<<endl;
cout << "Enter any thing to quit" << endl;
cout << "bye" << endl;
cin>> exit;
}
else
{
cout <<"Error:Invalid option. Select L-E-R"<<endl;
goto playgame; //going to the beginning and repeating all the previous steps
}
}
//***********************//
end:
return 0;
}