64,670
社区成员
发帖
与我相关
我的任务
分享
#include <iostream>
using namespace std;
enum note {middleC,Csharp,Cflat};
class Instrument{
public:
virtual void paly(note) const {
cout << "Instrument::play" <<endl;
}
};
class Wind : public Instrument {
public:
void play(note) const{
cout << "wind::play" << endl;
}
};
void tune(Instrument& i){
i.paly(Cflat);
}
int main(){
Wind flute; //这里却实例的是Instrument,实在不懂
tune(flute);
//Instrument* p=&flute;
//p->play(Cflat);
}