>Nothing was returned
Standard C++ returns 0 by default. Returning from main can be tricky, especially if you switch languages and work with legacy code a lot. In pre-standard C++ you need to explicitly return a value. In C89 you need to explicitly return a value. In standard C++ and C99, you can omit the return value and 0 will be returned automagically.
However, because C99 isn't widely implemented yet, everyone follows the intersection of C89 and C99 to avoid nonportable code during the interrim of changing from old standard to new standard. Since standard C++ is well implemented now, it's safe to omit the return value, but many still do it explicitly anyway as a matter of style and consistency.
My preference is to omit the return value unless I return failure, then I return success explicitly as well:
int main()
{
// Don't return anything explicitly
}
#include <cstdlib>
using namespace std;
int main()
{
if ( some_failure )
return EXIT_FAILURE; // Return failure here
return EXIT_SUCCESS; // And success here
}
>don't you have to put something inside the braces?
No, an empty block is legal. It's roughly equivalent to:
But that uses a semicolon, so it's not a valid solution for the problem.