is there a reason for putting a void in function parameters

I have seen that in a few places and I was wondering if there was a reason for it like speeding up the compiler or something like that I don't know, or is it just personal preference?

what I seen is something like this

Void function(void)
{

}

int main()
{

}
Not really, just preference.

Some people think it's clearer, some don't.

EDIT: Actually, I have no clue compiler-wise. It might optimise it in some way but I doubt it. Even then, I'd imagine it's probably quite marginal.
Last edited on
I always wondered, but never looked. ahaha

This site says it's optional, with no other infromation. So I'm guessing it's not faster in anyway.

Source:
http://www.cplusplus.com/doc/tutorial/functions/
(Bottom of the page ).
AFAIK, the presence of void in the argument list is a hangover from the old days of C before function prototypes were required. An argument list with void explicitly told the C compiler not to accept arguments, while the compiler might accept anything if type prototype had no arguments (probably compiler specific).

With C++, the presence of void makes no difference. An empty argument list and a void argument list generate the same mangled signature. Absolutely no difference in execution.
Topic archived. No new replies allowed.