📄 teacher.cpp
字号:
#include "teacher.h"
Teacher::Teacher(const char *name,const int id /* =-1 */,const Sex sex ):Person( name,id,sex)
{
}
Teacher::Teacher(const string name,const int id /* =-1 */,const Sex sex):Person(name,id,sex)
{
}
Teacher::Teacher(const Person & p):Person(p)
{
}
Teacher::Teacher(const Teacher & t):Person(t.name,t.id,t.sex)
{
}
Teacher::~Teacher()
{
}
// 是否可以重用Person的构造函数operator=( )呢?
Teacher& Teacher::operator =( const Teacher & t)
{
name = t.name;
id = t.id;
sex = t.sex;
return *this;
}
void Teacher::write( ostream& os)
{
os<<name<<"#";
os<<id<<"#";
os<<sex<<"#";
}
void Teacher::read( istream & is)
{
char tpName[20];
is.get(tpName,20,'#');
name=tpName;
is.ignore();
is>>id;
is.ignore();
if(is.get()=='0')sex = MALE;
else sex = FEMALE;
is.ignore();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -