return
Does
return instantly end the execution of the function at that spot and return to the "outer" function which executed the "inner" one?
1 2 3 4 5 6
|
int Function()
{
int a=0;
return a;
a=1;
}
|
Will a ever become 1 in this case or that line will NEVER be executed?
Another question: can
return;
be used like this, without an operand (or whatever its called), in functions with void return type?
Will a ever become 1 in this case or that line will NEVER be executed?
Another question: can return; be used like this, without an operand (or whatever its called), in functions with void return type? |
Yes, and yes.
But wouldn't testing it on your own be faster than waiting for a reply?
Any decent compiler with warnings turned on should give a warning such as
"foo.cpp(5): warning: statement will never be executed".
Topic archived. No new replies allowed.