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;
}

posted @ 2013-07-06 12:27  Predator  阅读(263)  评论(0编辑  收藏  举报