- Code: Select all
//Code that does stuff
- Should a function that takes no arguments be declared as Foo() or Foo(void)?
- Should a void function have a return statement?
- Should a constructor ever have a return statement?
With no arg functions, I've been using the latter, but I developed the habit while coding pure C. I've found one website that says function signatures of the form Foo() are preferred in C++ but no reasoning was given.
I've been putting a return statement at the end of every void function after reading somewhere that they should... Can't find the source. I'm not going to follow the school of "Only one return statement in a function, *EVER*" since that creates some ugly ugly code, but again, that's not the issue
I'm under the assumption that having a return statement in a constructor is a terrible idea, and as such I haven't been doing it, but I haven't really found anything that says either way.
Can anyone shed some light on the issue? Or at least knock me off the fence