In this code ar
and &ar
same. But isn't ar
just a constant pointer to ar[0]
?Then I suppose writing cout<<ar;
should give ar[0]
's memory adress while writing cout<<&ar;
should give it's own memory adress so they should be different. How they are same? Some say ar
is not a pointer than how cout<<*ar
is equal to ar[0]
's value if it is not a pointer to ar[0]
?
int ar[3] = {1,2,3};
cout<<ar<<endl;
cout<<&ar<<endl;
I mean in this code &a
and &b
are different which makes sense.
int a = 5;
int* b = &a;
cout<<&a<<endl;
cout<<&b<<endl;