⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 teacher.cpp

📁 继承与派生实验
💻 CPP
字号:
#include<iostream.h>
#include<string.h>
#include"Teacher.h"
Teacher::Teacher(char*na,int a,char*s,char*ad,char*tel,char*t)
		 {
			 name=new char[strlen(na)+1];              //开辟空间
			 strcpy(name,na);
			 age=a;
			 sex=new char[strlen(s)+1];                
			 strcpy(sex,s);
			 address=new char[strlen(ad)+1];
			 strcpy(address,ad);
			 telephone=new char[strlen(tel)+1];
			 strcpy(telephone,tel);
			 title=new char[strlen(t)+1];
			 strcpy(title,t);
		 }

void Teacher::display()                               //调用成员函数输出对象
{
	cout<<"姓名是: "<<name<<endl;
	cout<<"年龄是: "<<age<<endl;
	cout<<"性别是: "<<sex<<endl;
	cout<<"住址是: "<<address<<endl;
	cout<<"电话是: "<<telephone<<endl;
	cout<<"职称是: "<<title<<endl;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -