int* p_bob = new int;
*p_bob = 78;
The above code makes sense to me. I use the de-reference operation to allocation new memory and assign a value of 78.
int* p_dynint = new int[10];
*p_dynint[2] = 12;
This however doesn’t make sense. If I try to use the de-reference operator on p_dynint[] I get an error. Why would an array be any different?
*p_bob = 78;this assigns the value78to the memory pointed to byp_bob(which represents anint).p_dynint[2] = 12;simply accesses the 3rd element.p_dynint[2]is actually equivalent to*(p_dynint+2).