0

Why do advance compilers need return values and old compilers didn't?

old compilers for c++ used to compile and run programs without returning values then why do we now need main function to return value? what was the error that we used to get so as we needed to add return values as compulsory part of main function syntax too?

24th Feb 2017, 9:32 AM
Mitali Kasture
Mitali Kasture - avatar
1 Odpowiedź
0
Main is an int function. Int functions have to return values. Some new compilers will add a return 0; if you forget. Most do not. Main can technically be void and not return a value, but it doesn't make much sense. You have to handle exceptions and errors in C++, and without return codes, you'll be doing a lot of searching through good code, breaking things trying to find bugs. tl;dr return statements are used mainly for errors/successes
3rd Mar 2017, 3:31 PM
Thomas Rudolph
Thomas Rudolph - avatar