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

前端 未结 3 1443
栀梦
栀梦 2021-01-12 09:01

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

delete x;
delete(x);
相关标签:
3条回答
  • 2021-01-12 09:46

    No, there's absolutely no difference.

    0 讨论(0)
  • 2021-01-12 09:49

    It's the same as the difference between:

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

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

    0 讨论(0)
  • 2021-01-12 10:04

    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.

    0 讨论(0)
提交回复
热议问题