Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

deleting multiple pointers in one line. c++ [duplicate]

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

delete p1,p2,p3,p4,p5;  
like image 509
Anthony Raimondo Avatar asked Mar 28 '13 21:03

Anthony Raimondo


1 Answers

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.

like image 116
Joseph Mansfield Avatar answered Oct 29 '22 13:10

Joseph Mansfield