Consider these two function definitions:
void foo() { } void foo(void) { }
Is there any difference between these two? If not, why is the void argument there? Aesthetic reasons?
void
In C:
void foo()
foo
void foo(void)
In C++:
By writing foo(void), therefore, we achieve the same interpretation across both languages and make our headers multilingual (though we usually need to do some more things to the headers to make them truly cross-language; namely, wrap them in an extern "C" if we're compiling C++).
foo(void)
extern "C"
2.1m questions
2.1m answers
60 comments
57.0k users