The definition:
void main() { /* ... */ } |
Is not and never has been C++, nor has it even been C. See the ISO C++ standard 3.6.1[2] or the ISO C standard 5.1.2.2.1. A conforming implementation accepts
int main() { /* ... */ } Even if your compiler accepts “void main()” avoid it, or risk being considered ignorant by C and C++ programmers. Note also that neither ISO C++ nor C99 allows you to leave the type out of a declaration. That is, in contrast to C89 and ARM C++ ,”int” is not assumed where a type is missing in a declaration. Consequently:
is an error because the return type of main() is missing. It is never a good idea to use “void main()” or just “main()” as it doesn’t confirm standards. It may be allowed by some compilers though. |