Im having problems with classes?

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;
Oh and ive already defined my classes as this, the full program is alot longer but just edited out the important parts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
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.
Topic archived. No new replies allowed.