SDUTOJ 2713 5-3 多级派生类的构造函数
2014-10-17 11:46
302 查看
#include<iostream> #include<string> using namespace std; class Person { protected: string name; int age; char sex; public: Person(string nam, char s,int a) { name=nam; age=a; sex=s; } void display() { cout<<"name:"<<name<<endl; cout<<"age:"<<age<<endl; cout<<"sex:"<<sex<<endl; } }; class Employee:public Person { protected: int basicSalary,leavedays; public: Employee(string nam,char s,int a,int b,int l):Person(nam,s,a) { basicSalary=b; leavedays=l; } void show() { display(); cout<<"basicSalary:"<<basicSalary<<endl; cout<<"leavedays:"<<leavedays<<endl; } }; class Manager:public Employee { private: float performance; public: Manager(string nam,char s,int a,int b,int l,float p):Employee(nam,s,a,b,l) { performance=p; } void show_all() { show(); cout<<"performance:"<<performance<<endl; } }; int main() { string a; char b; int c,d,e; float f; cin>>a>>b>>c>>d>>e>>f; Manager t(a,b,c,d,e,f); t.show_all(); return 0; }
相关文章推荐
- 【继承与派生】SDUT 2713 - 5-3 多级派生类的构造函数
- [2713]5-3 多级派生类的构造函数
- SDUT-2713-->5-3 多级派生类的构造函数
- 【2713】 多级派生类的构造函数
- SDUT-2713 多级派生类的构造函数
- SDUTOJ 2712 5-2 派生类的构造函数
- 多级派生情况下派生类的构造函数
- 5-3 多级派生类的构造函数
- 5-3 多级派生类的构造函数
- 5-3 多级派生类的构造函数
- 5-3 多级派生类的构造函数
- 5-3 多级派生类的构造函数
- 5-3 多级派生类的构造函数
- sdut 5-3 多级派生类的构造函数
- 5-3 多级派生类的构造函数
- 5-3 多级派生类的构造函数
- 5-3 多级派生类的构造函数
- 多级派生情况下的派生类的构造函数
- 5-3 多级派生类的构造函数
- 5-3 多级派生类的构造函数