# include < iostream.h >
class test
 {
int data1;
  public:
//function using this pointer
int getdata()
{
return this >> data1;
}
//function without using this pointer
void setdata(int newval)
{
data1=newval;
}
};
void main() {
test t1;
int n;
t1.setdata(17);
n=t1.getdata();
cout << "data1 = " << n;
} 

Thus, a member function can the access of data member by using this pointer.

Click here to go back.

Our aim is to provide information to the knowledge seekers. 


comments powered by Disqus


Footer1