#include<iostream>
#include<iomanip>
using namespace std;
class Person{
private:
string name;
float age, height;
public:
Person(){
}
Person(string n, float g, float h){
name = n;
age =g;
height = h;
}
const void getInput(){
cout<<"Enter the person name\t"<<endl;
cin>>name;
cout<<"Enter the person age\t"<<endl;
cin>>age;
cout<<"Enter the person height\t"<<endl;
cin>>height;
}
const void showOutput(){
cout<<"Name\t"<<name;
cout<<setw(50)<<"\tThe age is\t"<<age<<"\tThe height is\t"<<height<<endl;
}
const bool isTaller(Person p){
if(p.height < this->height){
return true;
}
else{
return false;
}
}
};
int main(){
Person t1("Onyango",67,10);
Person t2("John",47,6);
Person t3("Ambrose",57,7);
Person o[3] ={t1,t2,t3};
Person t4 = t1;
if(t2.isTaller(t1) == true && t2.isTaller(t3) == true){
t4 = t2;
}
else if(t3.isTaller(t1) == true && t3.isTaller(t2)){
t4 = t3;
}
cout<<"The tallest person is\n";
t4.showOutput();
}
Comments
Thanks
Leave a comment