I have a function that validates whether certain coordinates are within a matrix and returns true/false depending on the answer:
bool validateNextLocation(char robot, int proposed_row, int proposed_col, char map[7][7]){
auto const robot_location = World::getRobotLocation(robot);
int row = robot_location -> first;
int col = robot_location -> second;
if (map[proposed_row][col] != '1' || map[row][proposed_col] != '1'){return false;}
else{return true;}
}
I am trying to use the function in my switch cases:
switch (direction) {
case 'L': {
if (World::validateNextLocation(robot, ++robot_location->first, robot_location-> second, char a[7][7])){
++robot_location->first;
}
else{return -1;}
}
break;
case 'D': {
if (World::validateNextLocation(robot, robot_location->first, --robot_location->second, char a[7][7])){
--robot_location->second;
}
else{return -1;}
}
break;
case 'R': {
if (World::validateNextLocation(robot, --robot_location->first, robot_location->second, char a[7][7])){
--robot_location->first;
}
else{return -1;}
}
break;
default: {
if (World::validateNextLocation(robot, robot_location->first, ++robot_location->second, char a[7][7])){
++robot_location->second;
}
else{return -1;}
}
break;
}
But the char a[7][7]
has a red underline where the error reads:
Expected '(' for function style cast or type construction
I know I'm not missing a bracket but where am I going wrong?