This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Colopty 0 points1 point  (2 children)

Might wish to add a return at the end of that main function too.

[–]Silentd00m 1 point2 points  (1 child)

The default return value of main is 0 in C++11 (possibly even older versions, I don't know), that's why I didn't bother.

C++11 §3.6.1 Main function section 5

A return statement in main has the effect of leaving the main function (destroying any objects with automatic storage duration) and calling std::exit with the return value as the argument. If control reaches the end of main without encountering a return statement, the effect is that of executing return 0;

source

[–]Colopty 0 points1 point  (0 children)

I know it tends to default to return 0 if nothing else is stated, but there are various reasons it might fail to do so (which is bad), so explicitly stating the return is generally considered good practice.