I am trying to understand why the following C ++ code does not compile
int main () {
int a[10];
int (*p)[10] = &a;
int *q = static_cast<int *>(++p);
}
If this is not obvious, then what I was trying to do was find a pointer to the end of the array using pointer arithmetic.
Until now, I understand that it phas a pointer to an array type of ten integers, as well as an expression ++p. Usually I can assign an array of ints to a variable of type pointer to int, but that did not work with the pointer ++p.
At first I tried without static_cast, but that didn't work either.
source
share