Sdutoj 2713 5-3 constructor of multi-level derived classes

Source: Internet
Author: User
Tags class manager
#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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.