一,使用this指针应注意的问题
下面的代码在编译时会出错
class A{
public:
~A(){
delete this;
this = NULL;
};
};
问题主要出在this = NULL上,因为在成员函数中this指针的类别是A *const this,this是一个常量只能使用不能修改。
一,使用this指针应注意的问题
下面的代码在编译时会出错
class A{
public:
~A(){
delete this;
this = NULL;
};
};
问题主要出在this = NULL上,因为在成员函数中this指针的类别是A *const this,this是一个常量只能使用不能修改。