Thursday, 5 September 2013

c++ return value in if statement

c++ return value in if statement

This is a really simple question.
Say I have a function :
int fun(int n){
if (n > 3)
return n;
else
fail(); // this function outputs error message
// and terminates the program
// no return value
}
Then there is no return value for cases where n <=3. How can this be fixed?

No comments:

Post a Comment