I'm really having trouble finding a code to compile my program but here it goes.
All i need is to create a "read" function to read all the data for a Player Object.
So Far i made a display function to display all the data for the "Player" object, but i don't know how to make a read function.
void displayPlayer(const vector<Player>& ePlayer);
void readPlayer(const vector<Player>&ePlayer, string pName, int ptype, int plevel, int pstrength, int wtype, int wdurability, int wlevRequired);
// main function ***********************************************************
int main()
{
vector <Player> gamePlayers;
string playerName;
int playerType, playerLevel, playerStregth, weaponType, weaponDurability, weaponlvlRequired;
// End of program statements
cout << "Please press enter once or twice to continue...";
cin.ignore().get(); // hold console window open
return EXIT_SUCCESS; // successful termination
}
void readPlayer(vector<Player> ePlayer,string pName, int ptype, int plevel, int pstrength, int wtype, int wdurability, int wlevRequired)
{
for (int i = 0; i < 3; ++i)
{
cout << "Enter player name: ";
cin >> pName;
cout << "Enter player type (1, 2, 3, 4): ";
ptype = readValidInteger(1, 4);
cout << "Enter player level (>=1 && <= 100):";
plevel = readValidInteger(1, 100);
cout << "Enter player strength (>= 25):";
pstrength = readValidInteger(25, 200);
cout << "Enter weapon type (1, 2, 3, 4): ";
wtype = readValidInteger(1, 4);
cout << "Enter weapon durability (>= 25):";
wdurability = readValidInteger(25, 200);
cout << "Enter weapon level required (>=1 && <=100): ";
wlevRequired = readValidInteger(1, 100);
"readPlayer" function you are using for filling the "gamePlayers", so we have to pass gamePlayers as reference to the function.
so please correct your read function as
void readPlayer(vector<Player>& ePlayer, string pName, int ptype, int plevel, int pstrength, int wtype, int wdurability, int wlevRequired);
Thank you so much for answering, I appreciate your help.
Everything seems fine so far now that i corrected it but when i try to compile my program.I get that all my local variables are not being used and i get the error.
The ones such as:
string playerName;
int playerType, playerLevel, playerStregth, weaponType, weaponDurability, weaponlvlRequired;
Or is it that i'm doing it wrong when i call the readPlayer function?
readPlayer(gamePlayers, playerType, playerLevel, playerStregth, weaponType, weaponDurability, weaponlvlRequired);
int main()
{
vector <Player> gamePlayers;
string playerName;
int playerType, playerLevel, playerStregth, weaponType, weaponDurability, weaponlvlRequired;
// End of program statements
cout << "Please press enter once or twice to continue...";
cin.ignore().get(); // hold console window open
return EXIT_SUCCESS; // successful termination
int main()
{
vector <Player> gamePlayers;
readPlayer(gamePlayers);
displayPlayer(gamePlayers);
// End of program statements
cout << "Please press enter once or twice to continue...";
cin.ignore().get(); // hold console window open
return EXIT_SUCCESS; // successful termination
}