Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there any difference between delete x and delete(x)?

Tags:

c++

In C++ is there any difference between the following commands:

delete x;
delete(x);
like image 408
gornvix Avatar asked Mar 13 '15 22:03

gornvix


3 Answers

No, there's absolutely no difference.

like image 121
emlai Avatar answered Nov 11 '22 13:11

emlai


It's the same as the difference between:

i = i + 1;
i = i + (1);

i.e. none. delete is an operator, not a function.

like image 32
Jonathan Potter Avatar answered Nov 11 '22 14:11

Jonathan Potter


The difference is only if the x is expanded by a pre-compiler, in which case the semantics of the (x) will cause an evaluation of the x expression before calling an operator delete on the result of that evaluation.

like image 40
YePhIcK Avatar answered Nov 11 '22 15:11

YePhIcK