单选题
有如下程序:
#include
using namespace std;
class Instrument{
public:
virtual void Display()=0;
};
class Pian0:public Instrument}
public:
void Display(){/*函数体略*" >
};
intmain(){
Instrument S;
Instrument*P=0:
//…;
return 0;
}
下列叙述中正确的是( )。
【正确答案】
B
【答案解析】本题考查纯虚函数和抽象类,纯虚函数是在声明虚函数时被“初始化”为0的函数,包含纯虚函数的类为抽象类,抽象类不能被实例化,所以语句“Instrmnent s;”在编译时出错。