I l @ ve RuBoard |
In C++, function prototyping is mandatory, but it is optional in C. This difference shows up if you leave the parentheses empty when declaring a function. In C, empty parentheses mean you are foregoing prototyping, but in C++ they mean the function has no prototypes. That is, in C++, the prototype
int slice();
means the same as the following:
int slice(void);
For example, the following sequence is acceptable, if old-fashioned, C but an error in C++:
int slice(); int main() { ... slice(20, 50); ... } int slice(int a, int b) { ... }
In C, the compiler assumes you used the older form for declaring functions. In C++, the compiler assumes that slice() is the same as slice(void) and that you failed to declare the slice(int, int) function.
Also, C++ allows you to declare more than one function of the same name , providing they have different argument lists.
I l @ ve RuBoard |