Thursday, 22 August 2013

`f(void)` meaning no paramters in C++11 or C?

`f(void)` meaning no paramters in C++11 or C?

In C++11 the following function declaration:
int f(void);
means the same as:
int f();
A parameter list consisting of a single unnamed parameter of non-dependent
type void is equivalent to an empty parameter list.
I get the (perhaps false) impression this is an old feature, perhaps
inherited from C?
Does anyone know the history or rationale behind this way to declare a
function with no parameters?

No comments:

Post a Comment