#include <iostream>
using namespace std;
class Teacher{
public:
string name;
string school;
virtual void goinclass() = 0;//纯虚函数不能被实例化 抽象类
virtual void startclass() = 0;//纯虚函数不能被实例化
virtual void afterclass() = 0;//纯虚函数不能被实例化
};
class MathTeacher:public Teacher{
public:
void goinclass() override
{
cout<<"MathTeacher goinclass"<<endl;
}
void startclass() override
{
cout<<"MathTeacher startclass "<<endl;
}
void afterclass() override
{
cout<<"MathTeacher afterclass"<<endl;
}
};
class EnglishTeacher:public Teacher{
public:
void goinclass() override
{
cout<<"EnglishTeacher goinclass"<<endl;
}
void startclass() override
{
cout<<"EnglishTeacher startclass "<<endl;
}
void afterclass() override
{
cout<<"EnglishTeacher afterclass"<<endl;
}
};
int main()
{
//Teacher t; //抽象类不能被实例化
MathTeacher r ;
r.goinclass();
Teacher *r1 = new EnglishTeacher;
r1->startclass();
return 0;
}