The following line interprets the value in a as an address:
p = (char *)a;
&p[b] is the address of the b th element of the array starting at p. So, as each element of the array has a size of 1, it's a char pointer pointing at address p+b. As p contains a, it's the address at p+a.
Finally, the following line converts back the pointer to an int:
sum = (int)&p[b];
But needless to say: it's a weird construct.
Additional remarks:
Please note that there are limitations, according to the C++ standard:
5.2.10/5: A value of integral type (...) can be explicitly converted to a pointer.
5.2.10/4: A pointer can be explicitly converted to any integral type large enough to hold it.
So better verify that sizeof(int) >= sizeof(char*).
Finally, although this addition will work on most implementations, this is not a guaranteed behaviour on all CPU architectures, because the mapping function between integers and pointers is implementation-defined:
A pointer converted to an integer of sufficient size (if any such
exists on the implementation) and back to the same pointer type will
have its original value; mappings between pointers and integers are
otherwise implementation-defined.