Yes this is C++ main is a void function so it returns not a thing. |
No, it is not.
main returns
int. The C++ definition is very, very clear.
main returns
int. The big, official document that explains what C++ actually is has it written very, very clearly. If your
main does not return
int, it's wrong. If your compiler doesn't complain, it is wrong as well (interestingly, I am told that MS Visual C++ doesn't complain - I'm not surprised - MS never did like having to conform to standards, including its own standards).
We always use main in the manner in my course. |
Your teacher is teaching you incorrect C++.
What you're doing in your course is not correct C++. I accept that you don't have a choice, but
at least now you know, so that if you ever have to use correct C++ you won't make this mistake.
I gather it is possible to get away with:
|
I think this is an old, old hangover from C. Back in the day, C would assume an
int return on a function that wasn't specified.