// demonstrates the use of this pointer // mikhail nesterenko // 11/22/99 #include using namespace std; // just a class with two member functions class myclass{ public: myclass(int i){data=i;}; void printdata(); private: int data; }; // prints the value of the member variable void myclass::printdata(){ cout << "the value stored in the object is: "; cout << this->data; // this points to the // the object that // invoked this function cout << endl; } // creates an object of myclass, prints // it's value int main(){ myclass obj(2); obj.printdata(); }