September 1998
Intermediate to advanced
848 pages
20h 13m
English
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, ...
Read now
Unlock full access