Hello world C++ program problem
quote:Original post by Drevay
The reason you got an error is because you forgot to put return 0; inside of your program. You always have to return a value when using int main() , and since you didn''t, the compiler get''s ''confused''.
No, no, no. main() certainly has to return an integer value, but like I already said, you do not have to do this explicitly - in C++, main() implicitly returns 0 unless otherwise specified. It certainly doesn''t hurt to do it explicitly, but on the other hand, I see no compelling reason to do so.
Well, of course using return 0; when no other value has to be returned...is just good programming practice. (IMO)
DigiCode - My solo company in progress
DigiCode - My solo company in progress
Well, that is a valid point of view. I just hate to think that people go around thinking you can''t live without it. My own way to look at it differs slightly from that: If main() never returns anything other than 0, the return value is meaningless, so I see little point in returning anything explicitly.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement