What is the difference between:
void foo(item* list)
{
cout << list[xxx].string;
}
and
void this(item list[])
{
cout << list[xxx].string;
}
Assuming item is:
struct item
{
char* string;
}
With the pointer pointing to the first of an array of chars
and list is just an array of items…
To the compiler, there is no difference.
It reads different though.
[]suggests you want to pass an array to the function, whereas*could also mean just a simple pointer.Note that arrays decay to pointers when passed as parameters (in case you didn’t already know).