MyArray - int*, sizeof(int*) - 4.
MyArraynot an array. This is a pointer that points to the memory block in which you allocated the array.
int MyArray[10];
cout << sizeof(MyArray) << endl;
This should print 40, which is a large 10 inton your system. In this case MyArray, it is an array. Thus, the size of this type includes the size of all elements of the array.
MyArray in this second case it will decay to a pointer, but they are still two different types.
source
share