?? mis.cpp
字號:
#include<iostream.h>
#include<string.h>
#include"mis.h"
person::person(char* s,int x,char y,long z)
{
name=new char[strlen(s)+1];
strcpy(name,s);
age=x;
sex=y;
no=z;
count++;
}
person::~person()
{
delete []name;
count--;
}
void person::display(void)
{
cout<<"姓名:"<<name<<" 年齡:"<<age<<" 性別:"<<sex<<" 總?cè)藬?shù):"<<count<<endl;
}
int person::count=0;
student::student(char* s,int w,char x,long y,int z,char *p):person(s,w,x,y)
{
credit=z;
spec=new char[strlen(p)+1];
strcpy(spec,p);
}
student::~student()
{
delete[]spec;
cout<<"學(xué)生消失"<<endl;
}
void student::display(void)
{
person::display();
cout<<"學(xué)號:"<<no<<" 專業(yè):"<<spec<<" 學(xué)分:"<<credit<<endl;
}
teacher::teacher(char* s,int w,char x,long y,int z,char **p):person(s,w,x,y)
{
salary=z;
for(int i=0;i<3;i++)
{
c[i]=new char[strlen(*(p+i))+1];
strcpy(c[i],*(p+i));
}
}
teacher::~teacher()
{
for(int i=0;i<3;i++)
delete []c[i];
cout<<"教師消失"<<endl;
}
void teacher::display(void)
{
person::display();
for(int i=0;i<3;i++)
cout<<"主講課程"<<i+1<<":"<<c[i]<<endl;
cout<<"教師號:"<<no<<" 薪水:"<<salary<<endl;
}
employee::employee(char* s,int w,char x,long y,int z,int t):person(s,w,x,y)
{
salary=z;
grade=t;
}
employee::~employee()
{
cout<<"機(jī)關(guān)人員消失"<<endl;
}
void employee::display(void)
{
person::display();
cout<<"工號:"<<no<<" 薪水:"<<salary<<" 級別:"<<grade<<endl;
}
tea_emp::tea_emp(char* s,int w,char x,long y,int z1,char **p,int z2,int t,float s1):
person(s,w,x,y),teacher(s,w,x,y,z1,p),employee(s,w,x,y,z2,t)
{
tea_emp::s=s1;
salary=employee::salary*s1+teacher::salary*(1-s1);
}
tea_emp::~tea_emp()
{
cout<<"兼職教師消失"<<endl;
}
void tea_emp::display(void)
{
person::display();
for(int i=0;i<3;i++)
cout<<"主講課程"<<i+1<<":"<<c[i]<<endl;
cout<<"工號"<<no<<" 級別:"<<grade<<" 分配比例:"<<s<<" 薪水:"<<salary<<endl;
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -