C++ 多态继承 求解释
程序代码:
#include <string.h> #include<iostream> using namespace std; enum note{middleC,Csharp,Cflat};//删掉就不能通过 class instrument{ public: void play(note) const{ cout<<"instrument::play"<<endl; } }; class wind:public instrument{ void play(note)const{ cout<<"wind::play"<<endl; } }; void tune(instrument& i){ i.play(middleC); } int main() { //wind flute; wind(flute); //这么定义为什么能通过??? tune(flute); system("pause"); return 0; }