5-3 多级派生类的构造函数
2017-12-21 22:01
369 查看
5-3 多级派生类的构造函数
Time Limit: 1000MS Memory Limit: 65536KBSubmit Statistic
Problem Description
要求定义一个基类3个name(char*类型sex(char类型age(int类型创建Employee,增加两个数据成员
基本工资 int类型) 请假天数int型);为它定义初始化成员信息的构造函数,和显示数据成员信息的成员函数创建Manager;增加一个成员
业绩 );为它定义初始化成员信息的构造函数,和显示数据成员信息的成员函数共如示例数据所示,共<font
face="\"Times" new="" roman,="" serif\"="" style="box-sizing: border-box;">5行,分别代表姓名、年龄、性别、基本工资、请假天数、业绩
Example Input
Jerry m 32 4200 1 100
Example Output
name:Jerry age:32 sex:m basicSalary:4200 leavedays:1 performance:100
Hint
#include<bits/stdc++.h> using namespace std; class person { protected: string name; char sex; int age; public: person() { cin>>name>>sex>>age; } void show() { cout<<"name:"<<name<<endl; cout<<"age:"<<age<<endl; cout<<"sex:"<<sex<<endl; } }; class employee:public person { protected: int salary, days; public: employee() { cin>>salary>>days; } void show1() { show(); cout<<"basicSalary:"<<salary<<endl; cout<<"leavedays:"<<days<<endl; } }; class manager:public employee { protected: float per; public: manager() { cin>>per; } void show2() { show1(); cout<<"performance:"<<per<<endl; } }; int main() { manager a; a.show2(); }
相关文章推荐
- sdut 5-3 多级派生类的构造函数
- 5-3 多级派生类的构造函数
- 5-3 多级派生类的构造函数
- 5-3 多级派生类的构造函数
- 2713 5-3 多级派生类的构造函数
- sdut 5-3 多级派生类的构造函数
- 5-3 多级派生类的构造函数
- 多级派生情况下的派生类的构造函数
- 5-3 多级派生类的构造函数
- 5-3 多级派生类的构造函数
- 多级派生情况下派生类的构造函数
- [2713]5-3 多级派生类的构造函数
- 5-3 多级派生类的构造函数
- 5-3 多级派生类的构造函数
- 多级派生情况下派生类的构造函数
- SDUT-2713 多级派生类的构造函数
- 【继承与派生】SDUT 2713 - 5-3 多级派生类的构造函数
- 5-3 多级派生类的构造函数
- 5-3 多级派生类的构造函数
- 5-3 多级派生类的构造函数