Write a program using This Pointer for returning address of object

 /*
    This Pointer for returning address of object
 */
 #include<iostream>
 using namespace std;

 class Test
 {
     int a,b;

    public:
            void show()
            {
                a=10;
                b=20;

                cout<<"\n\n Object Address: "<<this;

                cout<<"\n a="<<this->a;
                cout<<"\n b="<<(*this).a;
            }
 };

 int main()
 {
      Test t;

      t.show();

      return 0;
 }

Previous
Next Post »