My Herb Schildt book on C++ says: \"... In C++, if a function is declared as returning a value, it must return a value.\" However, if I write a function wit
It is mandatory--it is an undefined behavior when such function ends without returning anything (so compilers might actually implement some kind of special behaviour). However, there are some special cases.
::main
is an exception, it is assumed that return 0;
is at the end of its code.
Also, you don't have to return a value in a function that does not return cleanly, f.e.:
int Foo() {
throw 42;
}