Not declaring a function's return value is an error in C++, whether the function is main or not. In C99, the October 1999 revision to Standard C, not declaring a function's return value is also an error (in the previous version of Standard C an implicit int was assumed as the return value if a function was declared/defined without a return value). But the usual requirement of both Standard C++ and Standard C is that main should be declared to return an int. In other words, this is an acceptable form of main:
int main(void) { /* ... */ }
The problem is that this code declares main to return a void and that's just no good for a strictly conforming program. Neither is this:
implicit int not allowed in C++ or C99
main() { /* ...Whatever... */ }
Hope this helps,
-
Stack
Overflow
Following the
rules will ensure you get a prompt answer to your question. If posting code, please include BB
[code][/code] tags. Your question may have been asked before, try the
search facility.
IRC
Channel:
irc.daniweb.com
Room: #c, #shell