I have interesting question. Why this code is legal in C, but not legal in C++ ?
(tested with GCC 4.2 compilers)

void Function() {}

int main () {
   Function(1);
   return 0;
}

We can simulate same C++ compiler error in C compiler by changing function definition to void Function(void) {} So seems that if function is declared without parameters- C++ automatically substitutes VOID as parameter in function declaration, and C - does not.

The only question here is - Does that difference between C & C++ is documented / official ? Because I've not seen that difference documented in wikipedia here
Maybe I looked not in that direction or do we need to modify wiki, huh ? :)

Recommended Answers

All 2 Replies

Thanks for answer. Seems wikipedia is only suitable for introduction of target domain.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.