The C standard prohibit this. But I'm not sure what C++ standard says about this.
#include <iostream>
void bar() {
std::cout << "From Bar" << "\n";
}
void foo() {
std::cout << "From Foo" << "\n";
return bar();
}
int main()
{
foo();
return 0;
}
The program compiles and works just fine. I like the style of return bar(); instead bar(); return;
Is this legal in C++11?
The answer below mentions that it's legal on latest draft.