#include"iostream"
using namespace std;
class Parent01
{
public:
virtual void func() {
cout << "父类的func" << endl;
}
};
class Child01 :public Parent01//1.继承
{
public:
virtual void func() {//2.重写
cout << "子类的func" << endl;
}
};
void objTest(Parent01* p) {//3.父类指针指向子类对象
p->func();
}
int main() {
Child01 c1;
objTest(&c1);
Parent01 p1;
objTest(&p1);
system("pause");
return 0;
}