How does delete deal with pointer constness?

前端 未结 5 2026
不知归路
不知归路 2021-01-18 00:30

I was reading this question Deleting a const pointer and wanted to know more about delete behavior. Now, as per my understanding:

delete expressio

5条回答
  •  误落风尘
    2021-01-18 01:12

    const_cast doesn't really do anything – it's a way to suppress compiler moaning about const-ness of the object. delete keyword is a compiler construct, the compiler knows what to do in this case and doesn't care about const-ness of the pointer.

提交回复
热议问题