Q:

C++ pointer to different array

Assume I have an array a and an array b. Both have the same type and size but different values.
Now I create 3 or so pointers that point to different elements in a, you could say a[0], a[4] and a[13].
Now if I overwrite a with b via a=b - Where will the pointers point?
Do the pointers still point to their original positions in a but the values they point to are now those of b?

A:

Arrays are not assignable in C++.  Once you declare an array:
int a[10];

there is no way of overwriting it, only of changing the values it contains. Specifically, you can't do:
int a[10], b[10];
a = b;    // cannot work in C++ (or C)

If you create the array dynamically and assign pointers:
int * a = new int[10];
int * p = a + 1;
int * b = new int[10];
a = b;

then the pointer p still points into the first array, but you have  a memory leak.
In the case of a struct containing an array:
struct S {
    int a[10];
};

S s1, s2;
int * p = s1.a + 1;
s1 = s2;

then the pointer p still points into the first struct's array, but the array contents will have been overwritten with the array contents from the second struct.

