#include<iostream>
using namespace std;
class parent {
public:
virtual void fun() {
cout << "我是父类虚函数" << endl;
}
void fun2() {
cout << "我是父类普通函数" << endl;
}
};
class child :public parent {
public:
virtual void fun() {
cout << "我是子类虚函数" << endl;
}
void fun2() {
cout << "我是子类普通函数" << endl;
}
};
int main() {
parent* ptr = new child();
ptr->fun();//调用子类函数
ptr->fun2();//调用父类函数
system("pause");
return 0;
}