Anthony Raimondo Anthony Raimondo - 1 year ago 154
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;

Answer Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download