These of 2 of the probably many ways of declaring arrays (and allocating memory for them) in c++
1. int a[3];
2. int *b = new int[3];
I want to understand how c++ is treating the two differently.
a. In both cases, i can access array with the following syntax: a[1] and b[1]
b. When i try cout<< a and cout<< b, both print the addresses of first element of respective arrays.
It looks to me as if both a and b are being treated as pointers to first elements of arrays.
c. But strangely, when i try to do cout << sizeof(a) and sizeof(b) they print different values - 4 and 12 respectively.
I don't understand why in case of sizeof(b), the size of entire array is being printed.