Variable Random is not declared, did you mean this?
1 2 3 4 5 6 7 8 9 10
bool Weapon::did_you_hit(int Random, int hit_chance) {
if(Random <= hit_chance) { //braces not needed but I put them there in case I add more code later
returntrue;
}
else {
returnfalse;
}
}
This should be declared a const function because you are not changing the value of the arguments.
You could investigate the use of the ternary ?: operator as a short cut for if then else.
HTH
Edit:
Is there any way you can avoid posting code with line numbers? I had to manually delete each one.
Edit2:
You shoiuld have kept this in the other thread as they are so closely related. helios might spend time answering the same question in the other thread.