Is a return statement mandatory for C++ functions that do not return void?
- by AlwaysLearning
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 with a non-void return type and do not return anything, the compiler issues a warning instead of an error: "Control reaches end of non-void function."
I use gcc (MinGW) and have set the -pedantic flag.