Follow Us
Contribute
  • Register
Errorbase is a collaborative writing project, that aims to build the largest trouble-shooting guide about all kinds of error messages.

Categories

+1 vote

 

 

 

 

65 int BasicMonster::calculatePower() const

 

66 {
67 if (weight > stamina)
68 power -= (weight - stamina) * 2;
69 
70 if (health <= 0)
71 power = 0;
72 else if (health > 100)
73 power += (health - 100) * 3;
74 else if (health < 10)
75 power *= health / 10.0;
76 
77 return power;
78 }

 

Error 1 error C2166: l-value specifies const object 68
Error 2 error C2166: l-value specifies const object  71
Error 3 error C2166: l-value specifies const object  73
Error 5 error C2166: l-value specifies const object  75
 
 
Please, could you tell me what I have to write to not have errors?
 
 
 
 

requested by (130 points)

1 Solution

0 votes

I think removing out const will solve your problem. If there is no any specific reason for determining the function as constant, you can do that for a quick solution.

solved by (560 points)
...