we have
int a[2] = { 0, 1 } ;
std::cout << &a ;
std::cout << a ;
Now when I run it, the output is the same for both!
Of what I have understood is that a decays to a pointer and gives me the address of the first element of the array i.e address of a[0].
Which is similar to printing std::cout << &a[0].
Now shouldn't std::cout << &a give me an error as a itself returns a pointer ?
sizeofoperator or the address-of operator (unary&).aand&ahave different types, but both are convertible tovoid*.operator<<that takescoutand avoid *. All object pointers can be converted tovoid *, so there is no error.