关于多样性polymorphic问题
请问多样性特点是什么 如何修改一下程序中的getPropertyDetails和setPropertyDetails能让他产生多样性特点 谢谢class Owner
{
protected:
string name;
int mobile;
public:
Owner(string, int);
string getName();
int getMobile();
};
Owner::Owner(string Name, int Mobile)
{
name=Name;
mobile=Mobile;
}
string Owner::getName()
{
return name;
}
int Owner::getMobile()
{
return mobile;
}
class Property: public Owner
{
protected:
string addr;
int area;
public:
Property(string,int,string,int);
string getPropertyDetails();
void setPropertyDetails(string,int,string,int);
};
Property::Property(string Name, int Mobile, string Addr, int Area):Owner(Name, Mobile)
{
addr=Addr;
area=Area;
}
string Property::getPropertyDetails()
{
cout<<"Name: "<<name<<endl<<"Mobile: "<<mobile<<endl<<"Addr: "<<addr<<endl<<"Area: "<<area<<endl<<endl;
return (name, mobile,addr,area);
}
void Property::setPropertyDetails(string Name, int Mobile, string Addr, int Area)
{
name=Name;
mobile=Mobile;
addr=Addr;
area=Area;
}