I created an array of
int A[5] = {2,4,6,8,10};
and made two pointers
int *p=A, *q=&A[5];
since there's only five elements in the array, as far as I understand in c++, when there's nothing it's supposed to be zero.
When I try to print out
cout<<"*p = "<<*p<<endl;
cout<<"*q = "<<*q<<endl;
I got this one instead
*p = 2
*q = 32766
I might be wrong about pointer p, it's pointing to the the first element by default.
But I don't understand why such a huge value is printed in pointer q, even though it's not even memory address in heap.
Can someone explain to me what's happening?