我有一个关于const指针的基本问题.我不允许使用const指针调用任何非const成员函数.但是,我可以在const指针上执行此操作:
delete p;
这将调用类的析构函数,它实质上是一个非const'方法'.为什么允许这样做?它只是支持这个:
delete this;
还是有其他原因吗?
c++ const delete-operator
c++ ×1
const ×1
delete-operator ×1