Consider the following code:
#include <iostream>
int test(int a){
if (a > 10){
return a;
}
else{
std::cout << "Error!";
return nothing;
}
}
int main(){
std::cout << test(9);
return 0;
}
What I want is that The integer function test(int a)
, return a
if a > 10
, otherwise return Error!
. but since this is an integer function, it must return an integer value, but I want that it print Error and return nothing. Is there a way for do this? (Also note that I don't want to use a void function)