C++ Logo
C++二级在线二级在线
首页选择题程序题成为会员帮助其他科目

选择题

100. 有如下程序: #include<iostream> #include<string> using namespace std; class Instrument{ public: Instrument(string t, string n):type(t),name(n) { } virtual string GetType() const { return type; } virtual string GetName() const { return name; } protected: string type, name; }; class Piano:public Instrument{ public: Piano(string n="AB",string t="CD"):Instrument(n,t) { } string GetType() const { return type; } string GetName() const { return "YZ"; } }; int main(){ const Instrument &pi=Piano(); cout<<pi.GetType()<<'-'<<pi.GetName(); return 0; } 运行时的输出结果是______。

上一题