Hi,
I've seem to have a problem declaring an object within a switch statement. It keeps saying
error C2360: initialization of 'roll' is skipped by 'case' label
My code is as below
case 2:
// 25 % chance of being able to run.
int roll = Random(1, 4);
if( roll == 1 )
{
cout << "You run away!" << endl;
return true;//<--Return out of the function.
}
else
{
cout << "You could not escape!" << endl;
break;
}
There are three cases within the switch statement in total. Can somebody please give me some advice on how to solve this problem if it's possible.
Regards,
Perdana Putra