Bool Function Error

Below I have a bool function (I do not use bool functions a lot) that is supposed to have an error in it, but I do not understand what it is. I have experimented with the function, but I'm not sure what "return true" is supposed to look like. I have also assigned it "return false" and the output looks the same. So my question is: What is wrong with this function?

Thank you for your time.

1
2
3
4
  bool Greater (int a, int b){
  if (a > b)
    return true;
}
The problem is that if a <= b, then the function doesn't return anything.

So make it
1
2
3
4
5
6
bool Greater(int a, int b){
    if (a > b)
        return true;
    else
        return false;
}
or, more simply,
1
2
3
bool Greater(int a, int b){
    return a > b;
}
Oh that's true! I was too caught up in the bool function part, I didn't even notice. Many thanks!
Topic archived. No new replies allowed.