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 whether the program ended well or not?
Some C++ compilers allow the main function to have return type void . But
Share
C++ does not allow
mainto have avoidreturn type. The published C++ standard requires it to beint. Some C++ compilers allow you to usevoid, but that’s not recommended. In general, the OS doesn’t care one way or the other. A specific OS might require a program to give a return value, but it doesn’t necessarily have to come frommain‘s return value. If the C++ compiler allowsvoid, then it probably provides some other means of specifying the program’s exit code.