Anthony Raimondo Anthony Raimondo - 17 days ago 4
C++ Question

deleting multiple pointers in one line. c++

Does this delete all the pointers or does this just delete the first pointer p1?

delete p1,p2,p3,p4,p5;


It is equivalent to:

(((((delete p1),p2),p3),p4),p5);

That is, it deletes p1 and then the comma operator is applied to the result (of which there is none) and p2. The expressions p2 to p5 are simply evaluated and the results discarded.