0
The C++ standard specifies that the function "main()" MUST return a value of type "int". Therefore, the correct syntax is "int main()". If you write "main()" without return type or things like "float main()", i.e. with a type different from "int", it is just WRONG. That said, some compilers still accept something like "main()" or even "void main()" and forcefully set the return type to "int"; they usually give you a warning, though. I think that g++ accepts it, while clang doesn't (but I should check). TLDR: "int main()" is correct, "main()" is just wrong.
14th Jun 2017, 5:24 PM
Matteo SeclĂŹ
Matteo SeclĂŹ - avatar