Im trying to make a board game where it will keep track of where a person is on a board each time they roll. I can't get it to add up each roll of the dice.
Heres my error: error: cannot call member function ‘void Dice::setRolls(double)’ without object
Heres my code:
1 2 3 4 5 6 7 8 9 10 11 12 13
void Dice::setRolls(double rolls){
if (rolls<20);
rolls=10;
}
double Dice::getRolls(){
return(rolls);
}
int boardPosition=playerOne.getRolls()
cout<<boardPosition<<endl;
class Dice{
//Constructor
public:
Dice();
Dice(int);
double score();
double randPoints;
int pointTotal;
int a;
double getRolls();
void setRolls(double);
//methods
int roll();
void resetNumRolls();
int getNumRolls();
int playerPoints();
int compPoints();
int pointsTotal();
int computerTotal();
private:
//properties
int numRolls;
int numSides;
int numPoints;
int rollTotal;
double rolls;
};
error: cannot call member function ‘void Dice::setRolls(double)’ without object
Somewhere in your program you are either calling setRolls() without an argument, or you haven't instantiated a Dice object. If you don't have a Dice object, then you can't call any of the Dice class's functions.