In c++ primer
[qoute]
A return statement terminates the function that is currently executing and returns
control to the point from which the function was called. There are two forms of
return statements:
return ;
return expression ;
A function with a void return type may use the second form of the return
statement only to return the result of calling another function that returns void.
Returning any other expression from a void function is a compile-time error
A function with a void return type may:
a. not have a return statement
b. have an empty return statement
c. have a return statement where the expression is of type void
Example:
1 2 3 4 5 6 7 8 9 10 11
void fn_a( int& a ) { ++a ; } // fine: no return statement
void fn_b( int& a ) { fn_a(a) ; return ; } // fine: empty return statement
void fn_c( int& a ) { return fn_b(a) ; } // fine: return expression of type void
void fn_d( int& a ) { fn_c(a) ; returnvoid(0) ; } // fine: return expression of type void
void fn_e( int& a ) { fn_d(a) ; returnvoid( "hello world!" ) ; } // fine: return expression of type void
void fn_f( int& a ) { fn_e(a) ; returnthrow 123.45 ; } // fine: return expression of type void