Reputation: 1848
If I return a void function from a void function, will that function be called before returning?
example:
#include <iostream>
void one ( ) { std::cout << "Hello world.\n"; }
void two ( ) { return one ( ); }
int main ( ) { two ( ); }
Will "Hello world." be printed to the screen?
Upvotes: 3
Views: 287
Reputation:
Yes. From N3337 (draft C++11 standard):
[stmt.return]/3 A return statement with an expression of type
void
can be used only in functions with a return type of cvvoid
; the expression is evaluated just before the function returns to its caller.
Upvotes: 4
Reputation: 1848
Yes, "Hello world." will be printed to the screen, as function one
is called before function two
returns.
Upvotes: 5