I was just looking at someone else's code and they have an empty return statement at the end of a void function:
void someFunction (int* someArg, int someArg2, int someArg3) {
// some operations/function calls/recursion
return;
}
Is there a particular reason why it should be there?
There's no reason it needs to be there at the very end of a function, as far as I know. It's possible the function originally returned a value, someone changed it to a void
, and just replaced return value;
with return;
. Or someone not very experienced with C++ assumed that every function must have a return, and will blindly believe this to the bitter end.
Now, a return in the middle of a function is definitely relevant since it stops the execution of the function at that point.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With