C + + 5th experiment-Multiple inheritance

Source: Internet
Author: User

Project fill in the blanks

I. Questions and codes

#include <iostream> #include <string> using namespace std;  Class Person {string name;      name int age;        Age Public:person () {} void SetName (String na) {Name=na;        } void Setage (int a) {age=a;        } string GetName () {return name;        } int Getage () {return age;    }    };     Class Leader:public person//(1) {string job;     Post string dep;        Department Public:leader () {} void Setjob (string jb) {JOB=JB;              } void Setdep (char dp[]) {DEP=DP;        } string Getjob () {return job;        } string Getdep () {return DEP;    }    };     Class Engineer:public person//(2) {string major;      Professional string Prof; Title Public:engineer () {}       void Setmajor (String maj) {Major=maj;        } void Setprof (String pf) {PROF=PF;        } string Getmajor () {return major;        } string Getprof () {return prof;    }    };  Class Chairman:public Leader,public Engineer {private:int C;  Public:string name;      name int age;        Age person () {} void SetName (String na) {Name=na;        } void Setage (int a) {age=a;        } string GetName () {return name;        } int Getage () {return age;        }};//(3) int main () {Chairman C;        C.setname ("Zhang San");        C.setage (42);        C.setjob ("director");        C.SETDEP ("Technical Office");        C.setmajor ("turbine design");        C.setprof ("senior Engineer"); cout <<c.getname () << "," <<c.getage () << "old, served" &LT;&LT;C.GETDEP () <<c. Getjob () <<endl; cout <<c.getprof () << ", engaged in" << c.getmajor () << "professional" << ".        "<< Endl;    return 0;  }

ii. Results of Operation


Third, experience

Iv. Summary of Knowledge points

C + + 5th experiment-Multiple inheritance

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.