I am new to C++, and now am studying new
and delete
keywords.
Point ppaa = *new Point;
Point *p = &ppaa;
ppaa.xpos = 1;
ppaa.ypos= 3;
delete &ppaa;
delete p;
Could you please explain why I cannot delete the ppaa above using &ppaa? I know that delete can only operate on pointer, but I cannot understand why above is not possible since they are actually memory locations. Searching similar questions, it seems that this is related to the copying operations that happen at the first line, but I do not have good explanations.