My compiler doesn't give any warnings when I compile this. Is there something wrong with it, or is it just a feature of main?Code:int main() {
}
Printable View
My compiler doesn't give any warnings when I compile this. Is there something wrong with it, or is it just a feature of main?Code:int main() {
}
You mean, there is no return?
Main is a special function and the language standard - I think - requires that main return 0 if not specified explicitly.
The C++ standard says main returns 0 implicitly if no other value is returned.
This only applies to main. Any other function that returns any type other than void must explicitly return a value.
In short, no.
main() is the first function the operating system calls to envoke the program and that is obviously the starting point of the C/C++ program. If you did not include main then you would get a linker error asking you where it was.