Dec 10, 2015

Program in c++ to find Elder person using age

#include<iostream.h>
#include<conio.h>
class person
{
private:
char name[100];
int age;
public:void getdata()
{
cin>>name>>age;
}
void display()
{
cout<<name;
}
person operator>(person p)
{
if(age>p.age)
return *this;
else
return p;
}
};
void main()
{
clrscr();
person p1,p2,p;
cout<<"\n Enter the name and age of first pesron :";
p1.getdata();
cout<<"Enter the name and age of the second person : ";
p2.getdata();
p=p1>p2;
cout<<"Elder person is :";
p.display();
getch();
}

No comments:

Post a Comment