Okay, I didn't put the parenthesis in the showStrength thing where I pass the arguments for levelUp()'s paremeters, but I'm still getting the same problem. Here's the update of my code. What in the world is wrong?!
Code:
#include <iostream>
#include <string>
using namespace std;
//START STATS CLASS
class Stats
{
public:
Stats();
~Stats();
void setStrength(int str);
int showStrength();
void setDefense(int def);
int showDefense();
void setSpeed(int spd);
int showSpeed();
void setMagic(int mag);
int showMagic();
private:
int strength;
int defense;
int speed;
int magic;
};
//END STATS CLASS
//STATS FUNCTIONS DECLARACTIONS START
Stats::Stats(){};
Stats::~Stats(){};
void Stats::setStrength(int str) { strength = str; }
int Stats::showStrength(){ return strength; }
void Stats::setDefense(int def) { defense = def; }
int Stats::showDefense(){ return defense; }
void Stats::setSpeed(int spd) { speed = spd; }
int Stats::showSpeed(){ return speed; }
void Stats::setMagic(int mag) { magic = mag; }
int Stats::showMagic(){ return magic; }
//STATS FUNCTIONS DECLARATIONS END
//levelUp function start
void levelUp(int &, int &, int &, int &, string);
void levelUp(int &riStrength, int &riDefense, int &riSpeed, int &riMagic, string rRace)
{
if (rRace == "Dwarf") //about to incriment differently for each race
{
riStrength += 3;
riDefense += 2;
riSpeed += 2;
riMagic += 1;
}
else if (rRace == "Elf")
{
riStrength +=1;
riDefense += 2;
riSpeed += 2;
riMagic += 3;
}
else if (rRace == "Human")
{
riStrength += 2;
riDefense += 2;
riSpeed +=2;
riMagic +=2;
}
}
/*
NOTE: MUST LEVEL UP AS levelUp(
player->showStrength,
player->showDefense,
player->showSpeed,
player->showMagic,
charRace);
*/
//levelUp function end
int main()
{
//**variables**//
string charName;
string raceChoice;
unsigned short int raceCount = 0;
string charRace;
//**variables**//
//begin race selection
Stats * player = new Stats;
while (raceCount < 1)
{
cout<<"Dwarf\tElf\tHuman\n\n";
cout<<"What race will you be born?\n";
cout<<"Choice: ";
cin>>raceChoice;
cin.ignore();
if ((raceChoice == "Dwarf") || (raceChoice == "dwarf"))
{
//player stats if dwarf is chosen
player->setStrength( 12 );
player->setDefense( 10 );
player->setSpeed( 5 );
player->setMagic( 2 );
charRace="Dwarf";
raceCount++;
}
else if ((raceChoice == "Elf") || (raceChoice == "elf"))
{
//player stats if elf is chosen
player->setStrength( 2 );
player->setDefense( 5 );
player->setSpeed( 7 );
player->setMagic( 14 );
charRace="Elf";
raceCount++;
}
else if ((raceChoice == "Human") || (raceChoice == "human"))
{
//player stats if human is chosen
player->setStrength( 7 );
player->setDefense( 6 );
player->setSpeed( 8 );
player->setMagic( 7 );
charRace="Human";
raceCount++;
}
else
{
cout<<"\nThat is not a valid race.\n\n";
}
}
//end race selection
//begin name selection
cout<<"\nOkay, "<<charRace<<", now what is your name?\n";
cout<<"Name: ";
cin>>charName;
cin.ignore();
//end name selection
//begin player stats
cout<<"\n\n";
cout<<"Name:\t\t"<<charName<<endl;
cout<<"Strength:\t"<<player->showStrength()<<endl;
cout<<"Defense:\t"<<player->showDefense()<<endl;
cout<<"Speed:\t\t"<<player->showSpeed()<<endl;
cout<<"Magic:\t\t"<<player->showMagic()<<endl;
cout<<"\n";
//end player stats
//begin leveling up
levelUp(player->showStrength(),player->showDefense(),player->showSpeed(),player->showMagic(),charRace);
//end leveling up
//FREE MEMORY ALLOCATED
delete player;
//FREE MEMORY ALLOCATED
cin.get();
return 0;
}