Code for Program that provides an example of This pointer in C++ Programming
#include<iostream.h>
#include<conio.h>
class max
{
int a;
public:
void getdata()
{
cout<<"Enter the Value :";
cin>>a;
}
max &greater(max &x)
{
if(x.a>=a)
return x;
elsereturn *this;
}
void display()
{
cout<<"Maximum No. is : "<<a<<endl;
}
};
main()
{
clrscr();
max one,two,three;
one.getdata();
two.getdata();
three=one.greater(two);
three.display();
getch();
}