hey friends

what is the meaning of void as a parameter??
void add(void){}
No parameters.
That's a C99 construct, since in C90 an empty parameter list indicates that the function takes an unknown number of arguments. It is not C++, BTW, since Stroustrup detests it (and I agree).
it's also worth noting that this is a C thing and not a C++ thing. While that will compile in C++, it's redundant.

void add() { } <--- is the same thing in C++

EDIT -- bah I'm too slow
Last edited on
closed account (z05DSL3A)
It is not C++...
...not a C++ thing.

While I would agree that the (void) parameter list tends not to be used by C++ people, I would not go as far as to say it is not C++.
Stroustrup detests it?

It's a C99 construct?

It's not C++?

... not necessarily so. It's valid C and C++. I've seen plenty of industrial C++ using that form. GNU, Sun and Microsoft's C++ compiler seem happy enough.
I guess what I meant to say is that it's a C requirement and not a C++ requirement.

Yes it works in C++, but that's arguably only to maintain backwards compatibility with C.
Topic archived. No new replies allowed.