One disadvantage I can think of with int bar(int*)
is that it could make overloading more difficult. E.g.:
int areaOfRectangle(int width, int height);
int areaOfRectangle(int x1, int y1, int x2, int y2);
is fine, but how are you going to do that with arrays?
int areaOfRectangle(int* widthHeight);
int areaOfRectangle(int* coordinates); // error
The above won't compile because int areaOfRectangle(int*)
can't be declared/defined twice.
Also, if you're simply using an array as a way to arbitrarily group parameters, you make your code harder to read and use. Compare:
int calculateIncome(int normalHours,
int overtimeHours,
int normalRate
int overtimeRate); // Self documenting
int calculateIncome(int* parameters); // How do I use this function?
int calculateMean(int* numbers); // Parameters are logically grouped,
// so array makes sense
A third issue (which Sancho describes in his answer) is that int bar(int*)
is dangerous. What happens when the user calls your function a smaller array than the one you were expecting? A call to int Foo(int, int)
on the other hand, with the wrong number of parameters, will not compile.