2014-第12週プロジェクト二--教師兼幹部類
2529 ワード
/*
* :
*Copyright(c)2014,
*All rights reserved.
* :
* :
* :2014 05 13
* :v1.0
* :
* :
* :
* :
* :
* :
*/
#include <iostream>
#include<string>
using namespace std;
class Teacher
{
public :
Teacher (string nam,int a,int n,string add,char s,string t)
{
name=nam;
age=a;
tellnumber=n;
addr=add;
sex=s;
title=t;
}
void display()
{
cout<<"name:"<<name<<endl;
cout<<"age:"<<age<<endl;
cout<<"sex:"<<sex<<endl;
cout<<"addr:"<<addr<<endl;
cout<<"tellnumber:"<<tellnumber<<endl;
cout<<"title:"<<title<<endl;
}
protected:
string title;
string name;
int age;
char sex;
string addr;
int tellnumber;
};
class Cadre
{
public:
Cadre (string nam,int a,int n,string add,char s,string p)
{
name=nam;
age=a;
tellnumber=n;
addr=add;
sex=s;
post=p;
}
protected:
int age;
string name ;
int tellnumber;
string addr;
char sex;//x ,y
string post;
};
class Teacher_Cadre:public Teacher,public Cadre
{
public :
Teacher_Cadre(string nam,int a,int n,string add,char s,string p,string t,float w):
Teacher(nam,a,n,add,s,t),Cadre(nam,a,n,add,s,p),wages(w) {}
void show()
{
Teacher::display();
cout<<" :"<<post<<endl;
cout<<" :"<<wages<<endl;
}
private:
float wages;
};
int main()
{
Teacher_Cadre tc("wangli ",19,789478,"shandong",'m',"monitor","teacher",4000);
tc.show();
return 0;
}
多重継承が多いですね...コンストラクション関数に注意すべき問題はたくさんあります