T
thomas
Hi,
------------
class A {
public:
~A(){}
void Release(){ delete this; }
};
-----------
A *a = new A();
a->Release(); --> Method I
A a2;
a2.Release(); --> Method II
-----------
a is created in Heap while a2 is in Stack.
When I call "Release()", thus "delete this;" to these two different
kinds of object, what will happen?
If "delete this" just involves calling the destructor, I suppose they
are equivalent.
Any suggestions? Thanks.
tom
------------
class A {
public:
~A(){}
void Release(){ delete this; }
};
-----------
A *a = new A();
a->Release(); --> Method I
A a2;
a2.Release(); --> Method II
-----------
a is created in Heap while a2 is in Stack.
When I call "Release()", thus "delete this;" to these two different
kinds of object, what will happen?
If "delete this" just involves calling the destructor, I suppose they
are equivalent.
Any suggestions? Thanks.
tom