func(void) or func() ?
-
From the C++ standard: If the parameterdeclarationclause is empty, the function takes no arguments. The parameter list (void) is equivalent to the empty parameter list. Tim Smith I'm going to patent thought. I have yet to see any prior art.
-
main function can be declared as returning void or int both in C and C++. If you declare it as int, you let your program return a value (typically an error code) that operating system or calling process can use. Vagif Abilov MCP (Visual C++) Oslo, Norway Hex is for sissies. Real men use binary. And the most hardcore types use only zeros - uppercase zeros and lowercase zeros. Tomasz Sowinski
Vagif Abilov wrote: main function can be declared as returning void or int both in C and C++ Returning void is not standard C++. The standard C++ version of main is
int main()
{
}
There are only 10 kind of people in the world: those who understand binary and those who don't.
-
Since upgrading to VS.NET I have noticed that any classes I add using the "Add New Class" wizard will use
void
for functions with no params (such as constructors/destructors). Personally, I haven't bothered doing this sonce my C days, so my question is - are there any benefits tovoid
? What do you prefer for your member functions:void SomeFunc(void);
orvoid SomeFunc();
When I am king, you will be first against the wall.
I don't care, I decided to use only the following prototype for all of my C functions, and use casting till death!
void someFunc( const void * const * const args )
{}
and deal with it later ! Max.
-
Since upgrading to VS.NET I have noticed that any classes I add using the "Add New Class" wizard will use
void
for functions with no params (such as constructors/destructors). Personally, I haven't bothered doing this sonce my C days, so my question is - are there any benefits tovoid
? What do you prefer for your member functions:void SomeFunc(void);
orvoid SomeFunc();
When I am king, you will be first against the wall.
Robert Edward Caldecott wrote: void SomeFunc(void); This isn't C++ style it's C style
There are only 10 kind of people in the world: those who understand binary and those who don't.
-
I don't care, I decided to use only the following prototype for all of my C functions, and use casting till death!
void someFunc( const void * const * const args )
{}
and deal with it later ! Max.
:-) Well good for you! But shouldn't you be returning
void*
? Regards, Alvaro
Well done is better than well said. -- Benjamin Franklin
-
Stroustrup had an article in CUJ a couple of months ago on the subject "C and C++ compatibility", he mentions the empty parameter list vs. the void parameter list and one of them is supposed to mean that the function may take a parameter of any type, but I can't remember which... "After all it's just text at the end of the day. - Colin Davies "For example, when a VB programmer comes to my house, they may say 'does your pool need cleaning, sir ?' " - Christian Graus
I have that issue, I may pull it out. Christian No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002 Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002 During last 10 years, with invention of VB and similar programming environments, every ill-educated moron became able to develop software. - Alex E. - 12-Sept-2002