Raw arrays in C++ are used to store a collection of values of the same type.
* The size of an array is specified when it is declared and cannot change afterward.
* There is no index out of bounds checking in C/C++ raw array, so, some programs compile fine but may produce unexpected output when run.
A multidimensional array is an “array of arrays” and is declared by adding extra sets of indices to the array name.
```
#include <iostream>
using namespace std;
int main() {
int a[5] = {1, 2, 3, 4, 5};
int as[2][2] = {{1, 2}, {3, 4}};
int * ap = new int[5];
cout << a[2] << " " << as[1][1] << " " << ap[2] << endl;
delete[] ap;
return 0;
}
```
Arrays are always passed by pointers in functions, so to keep array information, we need to pass in a reference.
```
#include <iostream>
using namespace std;
template <class T, size_t n>
void findSize(T (&)[n])
{
cout << sizeof(T) * n << endl;
}
int main()
{
int a[10];
findSize(a);
float f[20];
findSize(f);
return 0;
}
```
In C++, expression E1[E2], and E2[E1] are identical (by definition) to *((E1)+(E2)),
```
#include <iostream>
int main() {
int a[10] = {1, 2, 3};
std::cout << 2[a];
}
```