a[0] = 0 // This is what happened when you set a
a[1] = 1
a[2] = 2
a[3] = 3
a[4] = 4
p[0] = a[0] = 0 // this is what happened when you set p
p[1] = a[2] = 2
p[2] = a[1] = 1
p[3] = a[4] = 4
p[4] = a[3] = 3
**ptr = p[0] = a[0] = 0 // this is what happened when you set ptr = p
**ptr = p[1] = a[2] - 2 // this is what happened after ++ptr
cout << **ptr = p[1] = a[2] = 2
<< ptr - p = p+1 - p = 1
<< *ptr - a = *(p+1) - a = a+2 - a = 2
Believe it or not, the ** doesn't do much in this line. It dereferences ptr, but it isn't used as there is nothing else in this line. Therefore, you can just read this as ++ptr which increments ptr from ptr = p to ptr = p+1.