Tenth to tenth week item four-teacher and cadre category

Source: Internet
Author: User

/* *copyright (c) 2016, College of Computer and Control engineering, Yantai University *all rights reserved * File name: 123.cpp * Author: Wang Lui * Completion date: May 10, 2016 * Version number: v1.0 * * Problem Description: Set separately The teacher class and the Cadre class are derived from these two classes in a multiple-inheritance manner teacher_cadre the new class.    */#include <iostream> #include <cstring>using namespace Std;class teacher{private:string title;    string address;    String name;    int age;    char sex; int Telephone;public:teacher (string n,int a,char s,string t,string ad,int Tel): Name (n), age (a), sex (s), title (t), address (AD), telephone (tel) {} void display ();};    void Teacher::d isplay () {cout<< "Name:" <<name<<endl;    cout<< "Age:" <<age<<endl;    cout<< "Sex:" <<sex<<endl;    cout<< "Title:" <<title<<endl;    cout<< "Address:" <<address<<endl; cout<< "Tel:" &LT;&LT;TELEPHONE&LT;&LT;ENDL;}    Class Cadre{private:string post;    string address;    String name;    int age;    char sex; int Telephone;public:cadre (string n,int a,char s,string p,string ad,iNT Tel): Name (n), age (a), sex (s), post (p), address (AD), telephone (tel) {} string printpost (); void display ();};    void cadre::d isplay () {cout<< "Name:" <<name<<endl;    cout<< "Age:" <<age<<endl;    cout<< "Sex:" <<sex<<endl;    cout<< "Post:" <<post<<endl;    cout<< "Address:" <<address<<endl; cout<< "Tel:" &LT;&LT;TELEPHONE&LT;&LT;ENDL;} String cadre::p rintpost () {return post;} Class Teacher_cadre:public Teacher,public cadre{private:double wages;public:teacher_cadre (string n,int a,char s,st Ring t,string p,string Ad,int tel,double W): Teacher (N,a,s,t,ad,tel), cadre (N,a,s,p,ad,tel), Wages (w) {} void Show ();    ; void Teacher_cadre::show () {Teacher::d isplay ();    cout<< "Post:" <<cadre::p rintpost () <<endl; cout<< "Wages:" &LT;&LT;WAGES&LT;&LT;ENDL;}    int main () {Teacher_cadre Colin ("Shu Baba", +, ' F ', "Professor", "Headmasters", "Zhongguo", 123456789,300000); Colin.show ();   return 0;} 

Operation Result:


Learning experience:
Learn how to solve problems with inheritance, as well as the constructors of derived classes.


Tenth to tenth week item four-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.