10th Week Item 4-Teacher and cadre category

Source: Internet
Author: User

/*copyright (c) 2016, *all Rights reserved, School of computer and Control engineering, Yantai University. * File name: My.cpp * Author: * Completion date: May 10, 2016 * Problem description:?  The teacher (teacher) class and the Cadre (Cadre) class are defined separately, and the new class Teacher_cadre (teacher and cadre) are derived from these two classes by multiple inheritance methods.  Requirements: (1) in two base classes include name, age, gender, address, telephone and other data members.  (2) The teacher class also contains the data member title (title), which also contains the data member post (title) in the Cadre class, and the data member wages (payroll) in the Teacher_cadre class.  (3) The name, age, gender, address, telephone and other data members in the two base classes are given the same name, specifying the scope when referencing the data members.  (4) Declare member functions in the class body, and define member functions outside the class. (5) In the member function of the derived class Teacher_cadre, call the display function in the teacher class, output name, age, gender, title, address, phone, and then use the cout statement to output the job and salary.    */#include <iostream>using namespace Std;class teacher{protected:string name;    int age;    string sex;     string ADR;    int p; String Title;public:teacher (String Nam,int a,string se, string adre,string title_, int num): name (NAM), age (a), sex (SE), a    Dr (Adre), title (Title_), p (num) {}; void Show () {cout<< "name:" <<name<< "<<" Age: "<<age<<" << "Sex:" <& lt;sex<< ' << ' adress: ' <<adr<< ' << ' tel-number: ' <<p<< ' <<"    Title: "<<title<<";    }};class cadre{protected:string name;    int age;    string sex;    string ADR;     String post;    int p; Public:cadre (String nam,int A, string se, string adre, int num,string posting): Name (NAM), age (a), sex (SE), ADR (Adre), p    (num), post (posting) {};    void Show () {cout<< "post:" <<post<< ";    }};class teacher_cadre:public teacher,public cadre{private:double wages; Public:teacher_cadre (String nam,int A, string se,string title, string adre, int num,string posting,double W): Teac        Her (nam,a,se,adre,title,num), cadre (nam,a,se,adre,num,posting), Wages (w) {};           void Show () {teacher::show ();            Cadre::show ();        cout<< "WAGs:" <<wages<<endl;    }};int Main () {Teacher_cadre T1 ("Zs", "Femal", "excelent teacher", "Beijing", 121212, "leader", 8888);    T1.show (); return 0;}

10th Week Item 4-Teacher and cadre category

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.