#include<iostream>
using namespace std;

class Test
{
private:
  int x;
  int y;
public:
  Test(int x = 0, int y = 0) { this->x = x; this->y = y; }
  void setX(int a) { x = a; }
  void setY(int b) { y = b; }
  void destroy()  { delete this;
    cout<<"x="<<this->x<<",y= "<<this->y;
  }
  void print() { cout << "x = " << x << " y = " << y << endl; }
};

int main()
{
  Test *obj=new Test();
 (*obj).setX(10);
 (*obj).setY(20);
 (*obj).destroy();
  (*obj).print();
  return 0;
}

i created object dynamically yet how it is still able to print values of x
& y even after deletion of object through 'this' .

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].


Reply via email to