Whats the difference between function(void); and function();?
Printable View
Whats the difference between function(void); and function();?
void fun() is treated as
void fun(...) in C.
Here ... stands for ellipse, which means variable list of arguments
void fun() is treated as
void fun(void) in C++.
This means there is no real difference between void fun() and void fun(void) in C++.
when you use function(void) your compiler automatically assumes that its arguments are "void". Not sure about C but its definately like that for C++.
As far as I know, in C++, int func(void); and int func();
are exactly the same. Explicitly stating void just makes your intentions clear that the function takes no arguments.
-Futura