Thursday 3 July 2014

C++ program to print address of an object using this pointer


Here is a C++ program to print address of an object using this pointer


 SOURCE CODE OUTPUT
#include<iostream>
using namespace std;
class address{
public:
    void show()
    {
        cout<<"Address of this object is : "<<(unsigned)this;
    }

};
int main()
{
    address obj;
    obj.show();
    return 0;
}

Any questions regarding to program please write in comments.

No comments:

Post a Comment