📄 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<<" 总人数:"<<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<<"学生消失"<<endl;
}
void student::display(void)
{
person::display();
cout<<"学号:"<<no<<" 专业:"<<spec<<" 学分:"<<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<<"机关人员消失"<<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;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -