After using 'delete this' in a member function I am able to access other member functions. Why?
问题 I just wrote a sample program to see the behaviour of delete this class A { ~A() {cout << "In destructor \n ";} public: int a; A() {cout << "In constructor \n ";} void fun() { cout << "In fun \n"; delete this; cout << this->a << "\n"; // output is 0 this->fun_2(); // how m able to call fun_2, if delete this is called first ?? } void fun_2() { cout << "In fun_2 \n"; } main() { A *ptr = new A; ptr->a = 100; ptr->fun(); //delete this will be executed here ptr->fun_2(); //how m able to execute