A function parameter having an array type is implicitly adjusted by the compiler to pointer to the array element type.
So for example these function declarations
void f( T a[] );
void f( T a[1] );
void f( T a[100] );
where T
is some arbitrary type as for example
class Class
{
//…
};
declare the same one function that is equivalent to the declaration
void f( T *a );
You may include all these declarations in one compilation unit though the compiler can issue a warning that these declarations are redundant.
On the other hand, an array passed to such a function is in turn implicitly converted to pointer to its first element.
Of course you can even pass to such a function a pointer to a single object instead of specifying an array as an argument because in any case the function deals with a pointer.
Here is a demonstrative program.
#include <iostream>
class Class
{
public:
int x = 10;
};
void f( Class object[] );
// The definition of the above function
void f( Class *object )
{
std::cout << object[0].x << '\n';
}
int main()
{
Class object;
Class objects[10];
f( &object );
f( objects );
return 0;
}
Its output is
10
10