There is no difference in C++
.
The second declaration explicitly states that the function does not accept any parameter.
The second is more commonly used in C
The first is one that is more common in C++
.
In case C
there is a difference because:
Using (void)
you indicate that the function has no parameters, and with ()
you indicate that the parameters are unspecified (unknown number of arguments).
However, if it is not a function declaration, but a function definition, then even in C
it will be the same as (void)
.
source share