I was recently reading about difference between T*
and T[size]
, T being the type, and it make me curious so I was playing around with it.
int main()
{
int a[10];
using int10arrayPtr_t = int(*)[10];
int10arrayPtr_t acopy = a;
}
In the above code, int10array_t acopy = a;
is an error with message
error C2440: 'initializing':
cannot convert from 'int [10]' to 'int10array_t'
And this compiles:
int main()
{
int a[10];
using int10arrayPtr_t = int*;
int10arrayPtr_t acopy = a;
}
Isnt the type int(*)[10]
closer the the type of int a[10];
than int*
? So why does it not allow the first case?