Hello there, so I would like to know if you can make a pointer or reference to a whole array. I`m using the pointer or reference in a function and that needs to modify the the array that its pointing at or is a reference of
void f ( T (& arr)[ N ] ) // pass array by reference
{
// ... access elements by arr[i]
}
void f ( T* arr, size_t size ) // pass by pointer
{
// ... access elements by arr[i]
}
Yes of course you can, in fact if you use the variable name of an array without the element access operator then that behaves as a pointer to that array which is more or less how C-strings work.
What do you mean a whole array?
C style arrays such as int Foo[500]; essentially _are_ pointers (that is, Foo in this example is a pointer to the first element of a 500 long array of ints)
I`m using the pointer or reference in a function and that needs to modify the the array that its pointing at or is a reference of