Some C++ compilers allow the main function to have return type void. But doesn\'t the Operating System require int type value returned to specify
C++ allows main function to have return type void
No, it doesn't.
The C++ standard only requires 2 different types of main signatures. Others may be optionally added if the return type is int.
Implementations of C++ which allow void return types are incorrect in terms of the C++ standard.
C++03 standard S. 3.6.1-2:
An implementation shall not predefine the main function. This function shall not be overloaded. It shall have a return type of type int, but otherwise its type is implementation-defined. All implementations shall allow both of the following definitions of main:
int main() { /* ... */ } int main(int argc, char* argv[]) {/* ... */ }
If you want portable C++ code, or to write good C++ examples then you should always use one of the 2 variations above.