8053:根据题目要求填写代码A

Time/Memory Limit:1000 MS/32768 K
Submitted: 314 Accepted: 213

 Problem Description

以下代码描述了类之间的包含等关系,请仔细阅读。在“/*自己填写代码*/”注释处写入正确的代码,使得程序
运行正常。
#include <iostream>
using namespace std;

class Employee;
class Eye{
public:
 Eye(double sight){
  this->sight=sight;
 }
 /*自己填写代码*/
private:
 double sight;
};
class House{
public:
 House(){

 }
 House(double area,double rent){
  this->area=area;
  this->rent=rent;
 }
 ~House(){
  cout<<"resign,giving the company back the house."<<endl;
 }
 /*自己填写代码*/
public:
 void showHouseInfo()const{
  cout<<"area:"<<area<<","<<"rent:"<<rent<<endl;
 }
private:
 double area;
 double rent;
};
class Human{
public:
 Human(int id,double sight):/*自己填写代码*/{
  this->id=id;
 }
protected:
 int id;
 Eye eye;
};

class Employee:/*自己填写代码*/{
public:
 Employee(int id,double sight,int welfareID):Human(id,sight){
  this->welfareID=welfareID;
  pHouse=NULL;
 }
 ~Employee(){
  /*自己填写代码*/
  pHouse=NULL;
 }
public:
 void rentHouse( double area,double rent){
  pHouse=new House(area,rent); 
 }
 void showEmployeeInfo(){
  cout<<"id:"<<id<<","<<"welfareID:"<<welfareID<<","<<"eyeSinght:"<<eye.sight<<",";  
  pHouse->showHouseInfo();
 }
private:
 int welfareID;
 House*pHouse;
};


int main(){
 double houseArea,houseRent;
 int id;
 double eyeSight;
 int welfare;

 cin>>houseArea>>houseRent>>id>>eyeSight>>welfare;

 
 Employee emp(id,eyeSight,welfare);

 emp.rentHouse(houseArea,houseRent);
 emp.showEmployeeInfo();

 return 0;
}
 

 Input

输入占一行,分别给houseArea、houseRent、id、eyeSight和welfare赋值,各个值之间以空格分割。

 Output

程序已经限定了输出格式。

 Sample Input

60 350 1 5.5 100

 Sample Output

id:1,welfareID:100,eyeSinght:5.5,area:60,rent:350
resign,giving the company back the house.

 Author

wtf

 Recommend

zh