|
(31)有如下程序 #include using namespace std; Class Base{ public: Base(int x=0):valB(x) {cout< ~Base() {cout< private: int valB; }; class Derived:public Base{ public: Derived(int x=0,int y=0):Base(x),valD(y){cout< ~Derived() {cout< private: int valD; }; int main(){ Derived obj12(2,3); retuen 0; } 运行时的输出结果是 A)2332 B)2323 C)3232 D)3223 (32)下面是类Shape的定义: class Shape{ public: virtual void Draw()=0; }; 下列关于Shape类的描述中,正确的是 A)类Shape是虚基类 B)类Shape是抽象类 C)类Shape中的Draw函数声明有误 D)语句“Shape s;”能够建立Shape的一个对象s (33)将运算符“+”重载为非成员函数,下列原型声明中,错误的是 A)MyClock operator + (MyClock,long); B)MyClock operator + (MyClock,MyClock); C)MyClock operator + (long,long); D)MyClock operator + (long,MyClock); (34)打开文件时可单独或组合使用下列文件打开模式 ①ios_base::app ②ios_base::binary ③ios_base::in ④ios_base::out 若要以二进制读方式打开一个文件,需使用的文件打开模式为 A)①③ B)①④ C)②③ D)②④ (35)有如下程序: #include using namespace std; Class B{ public: B(int xx):x(xx) {++cout; x+=10;} virtual void show() const {cout< protected: static int count; private: int x; }; class D:public B{ public: D(int xx,int yy):B(xx),y(yy) {++count; y+=100;} virtual void show() const {cout< private: int y; }; int B::count=0; int main(){ B *ptr=new D(10,20); ptr->show(); delete ptr; return 0; } 运行时的输出结果是 A)1_120 B)2_120 C)1_20 D)2_20 (责任编辑:admin) |