this Pointer
<iostream>
<cstring>
using namespace std;
class person
{
name[20];
age;
:
person( *s, a)
{
strcpy(name,s);
age=a;
}
person & person :: greater(person &x)
{
(x.age>=age)
x;
*this;
}
display()
{
cout << "Name:" << name << "\n"
<< "age:" << age << "\n";
}
};
main()
{
person p1("john",37.50),
p2("ahmed",29.0),
p3("Hebber",40.25);
person p=p1.greater(p3);
cout << "Elder person is: \n";
p.display();
p=p1.greater(p2);
cout << "Elder person is: \n";
p.display();
0;
}
|