class Bird
{
public:
Bird();
virtual ~Bird();
void fly();
virtual void tweet();
virtual void breed()=0;
};
class Eagle : public Bird
{
public:
Eagle() : Bird() {}
virtual ~Eagle();
void fly();
void tweet();
void breed();
};
这时,有如下使用情况
Bird * ha = new Eagle();
ha->fly(); //这是一个普通的重载,取决于ha的声明类型
ha->tweet(); //由于virtual让它指向new的类型
ha->breed(); //同上
delete ha;