Use of this pointer
#include<bits/stdc++.h>
#include<fstream>
using namespace std;
class test
{
int x;
public :
void getdata(int x)
{
this ->x=x;
}
void show()
{
cout<<x<<endl;
}
};
int main()
{
test t;
t.getdata(5);
t.show();
return 0;
}
Use of this pointer
#include<bits/stdc++.h>
#include<fstream>
using namespace std;
class test
{
int x;
public :
void getdata(int x)
{
this ->x=x;
}
void show()
{
cout<<x<<endl;
}
};
int main()
{
test t;
t.getdata(5);
t.show();
return 0;
}
0 Comments