#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;}
Sdutoj 2713 5-3 constructor of multi-level derived classes