C++基类类不能指向派生类
#include <iostream>
#include <string>
using namespace std;
class CPerson
{
public:
CPerson(){}
~CPerson(){}
virtual void Walk(){cout << "CPerson Walk" << endl;}
};
class CManager: public CPerson
{
public:
CManager(){}
~CManager(){};
virtual void Walk() {cout << "CManager Walk" << endl;}
virtual void SendCommand(){cout << "CManager Send Command" << endl;}
};
void main()
{
CPerson *person;
CManager *manager;
person = new CManager();
person->Walk();
/// manager = new CPerson; //注意这里报错
int wait;
cin >> wait;
}