View Single Post
  #8 (permalink)  
Old 07-07-2007, 06:09 PM
rpgfan3233 rpgfan3233 is offline
PT Staff
Awards Showcase
Quality Tutorial Quality Tutorial Quality Tutorial Quality Tutorial 
Total Awards: 4
Join Date: Jul 2007
Posts: 118
iTrader: (0)
rpgfan3233 has a spectacular aura aboutrpgfan3233 has a spectacular aura aboutrpgfan3233 has a spectacular aura aboutrpgfan3233 has a spectacular aura aboutrpgfan3233 has a spectacular aura about
Quote:
Originally Posted by HelloWorld View Post
Would the compiler return some kind of an exception if we don't put int return value in the main method? Well, I personally interested in C# more than C++ though for ASP.NET, but I'm just wondering at least to add up for my knowledge
A compliant compiler will either display an error and refuse to compile the program or compile the program after issuing a warning about the practice.

As somebody already mentioned, returning an integer rather than nothing at all is better because then you can determine whether the program exited due to errors. In fact, on many Linux machines, you can print out a special variable to determine the exit success:
g++ -std=c++98 -o myprog myprog.cpp && myprog
# the program output is here
echo $?
# if $? shows 0, then myprog exited fine (it exited with 0 errors)

As a side note, this is contrary to many other programming implementations, such as the Windows API, where if you return 0 from a function, that means that the function did not exit successfully (did you exit successfully? 0/FALSE).

__________________

Digg this Post! Del.Icio.Us this Post! Technorati this Post! Furl this Post! Mister Wong this Post! Newsvine this Post! Spurl this Post! Reddit this Post! Netscape this Post!
Reply With Quote
The Following User Says Thank You to rpgfan3233 For This Useful Post:
HelloWorld (07-08-2007)