下列程序中,划线处正确的语句是()。#includeusing namespace std;class Base{public:void fun() {cout<<”Base::fun”<
A. fun()
Base.fun()
C. Base::fun()
D. Base->fun()
查看答案
下列程序中,编译时不会出错的语句是()。#includeusing namespace std;class Base{public:Base(){}Base(int i){data=i;}private:int data;};class Derived:public Base{public:Derived():Base(0)Derived(int x):Base(x)};int main(){ Derived d1(1);Base *pb,b1;pb=&d1 //Ad1=b1; //BBase &refB=d1;Derived d2=*pb; //CDerived &refD=refB //Dreturn 0;}
A. pb=&d1
B. d1=b1;
C. Derived d2=*pb;
Derived &refD=refB
请将如下程序补充完整,使程序的输出结果为:B0:1B1:2B2:3D:123源程序清单:#include using namespace std;class B0{ public:B0(int x){a=x;}void f (){cout<<"B0:"<
请将如下程序补充完整,使程序的输出结果为:b=0,d=0b=1,d=2源程序清单:#include using namespace std;class Base{ public:[1] {b=x;}protected:int b;};class Derived: public Base{ int d;public:Derived():d(0){}Derived(int m,int n): [2] {}void print(){cout<<"b="<
请改正程序中的错误,使程序的输出结果如下:Base1Base23,1,4注意:(1)只修改注释的下一行,不要改动程序中的其它内容,也不允许增加或删减语句。(2)写出修改后完整的一行。#include using namespace std;class Base{public:Base1(int x){b1=x; cout<<”Base1”<