robatino's statement was with respect to the global main() function, which returns an int, and which specifically returns 0 if control does not reach a return statement within it.At best it returns void. Not 0.
robatino's statement was with respect to the global main() function, which returns an int, and which specifically returns 0 if control does not reach a return statement within it.At best it returns void. Not 0.
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
Ah. I'm too distracted it seems. Need a rest.
Originally Posted by brewbuck:
Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.
There have been buggy compilers from time to time that were so broken that they required a return at the end of each function, even those that didn't return anything.
But nowadays, I would personally consider it a very strange habit if a programmer put an explicit return at the end of each function. Waste of a line and 7 characters, and it's so easy to accidentally put it in the wrong place, at least when later rearranging a function.
All the buzzt!
CornedBee
"There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
- Flon's Law
@vart: But again, you can use if(a != b) and put your code in the if() block without using an empty return.
That's true, Des, but that can get very messy if there are a large number of conditions where you want to short-circuit out.
Naturally I didn't feel inspired enough to read all the links for you, since I already slaved away for long hours under a blistering sun pressing the search button after typing four whole words! - Quzah
You. Fetch me my copy of the Wall Street Journal. You two, fight to the death - Stewie
Also, if there are a large number of lines after the condition, they all have to be indented an extra level, which takes up more space than a single extra return, and I think makes the code harder to understand.Originally Posted by XSquared