C
Cheney Stallman
I have a class as following:
class X
{
public:
static X* Create()
{
return new X();
}
void Destroy()
{
delete this;
// try assign this to NULL, but failed.
this = NULL;
}
private:
X(){}
};
int main()
{
X* pX = X::Create();
pX->Destroy();
// test the validation of pX.
// I want the Destroy function set the pX to NULL.
if (pX){
// do something
}
return 0;
}
My problem is on line compiler complain error:
this=NULL;
Does there exist some method to set the this pointer to NULL?
Any response is appreciate.
class X
{
public:
static X* Create()
{
return new X();
}
void Destroy()
{
delete this;
// try assign this to NULL, but failed.
this = NULL;
}
private:
X(){}
};
int main()
{
X* pX = X::Create();
pX->Destroy();
// test the validation of pX.
// I want the Destroy function set the pX to NULL.
if (pX){
// do something
}
return 0;
}
My problem is on line compiler complain error:
this=NULL;
Does there exist some method to set the this pointer to NULL?
Any response is appreciate.