网友您好, 请在下方输入框内输入要搜索的题目:
题目内容
(请给出正确答案)
有如下程序: Class Base{ publiC: int data; }; Class Derivedl:publiC Base{}; Class Derived2:proteCted Base{}; int main( ) { Derivedl dl; Derived2 d2; dl.data=0;//① d2.data=0;//② retum 0; } 下列关于程序编译结果的描述中,正确的是( )。
A.①②皆无编译错误
B.①有编译错误,②无编译错误
C.①无编译错误,②有编译错误
D.①②皆有编译错误
参考答案
更多 “ 有如下程序: Class Base{ publiC: int data; }; Class Derivedl:publiC Base{}; Class Derived2:proteCted Base{}; int main( ) { Derivedl dl; Derived2 d2; dl.data=0;//① d2.data=0;//② retum 0; } 下列关于程序编译结果的描述中,正确的是( )。A.①②皆无编译错误B.①有编译错误,②无编译错误C.①无编译错误,②有编译错误D.①②皆有编译错误 ” 相关考题
考题
下列类的定义中,有( ) 处语法错误。 class Base { public: Base(){} Base(int i) { data=i; } private: int data; }; class Derive: public Base { public: Derive(): Base(O) { } Derive(int x) { d=x; } void setvalue(int i) { data=i; } private: d; };A.1B.2C.3D.4
考题
下列程序的运行结果是【 】。 include class SomeClass { public: SomeClass(int va
下列程序的运行结果是【 】。include <iostream. h>class SomeClass{public:SomeClass(int value) { some_value=value;};void show_data(void) { cout<<data<<"<<~some_value<<endl; };static void set_data(int value) {data=value; }private:static int data;int some_value};int SomeClass::datavoid main(void){SomeClass my_class(1001),your_class(2002);your_class. set_data(4004);my_elass. show_data()}
考题
在下面程序中,A、B、C、D四句编译时不会出错的是()。include using namespace std;class
在下面程序中,A、B、C、D四句编译时不会出错的是( )。 #include <iostream> using namespace std; class Base{ public: Base(); Base(int e):count(C) {} virtual void print() const = 0; private: int count; }; class Derived :public Base{ public: Derived():Base(0) {} Derived(int C) :Base(C) {} void printt() const{cout<< "Derived"<<endl:} }; void main( ) { Derived d(10); Base *pb; pb = d; //A Base cb= d; Derived dd = *pb; //B Derived cd = cb; //C Base bb = d; //DA.AB.BC.CD.D
考题
有以下程序:include using namespace std; class Base { public: Base() { K=0; } int
有以下程序:include<iostream>using namespace std;class Base{public:Base(){K=0;}int x;};class Derivedl:virtual public Base{public:Derivedl(){x=10;}};class Derived2:virtua1 public Base
考题
下列类的定义中,有( )处语法错误。 class Base { public: Base(){} Base(int i) { data=i; } private: int data; }; class Derive : public Base { public: Derive() : Base(0) {} Derive (int x) { d=x; } void setvalue(int i) { data=i; } private: d; };A.1B.2C.3D.4
考题
在下列横线处应添加的语句是( )。 class Base{public:void fun(){cout<<"Base::fun"<<end1;}}; class: Derived: public Base { public: void fun() { ______//显示调用基类的fun函数 cout<<"Derived::fun"<<end1; } };A.Derived::funB.Base::fun();C.Pubic::funD.fun();
考题
下列类的定义中,有( )处语法错误。 class Base { public: Base(){} Base(int i) { data=i; } private: int data; }; class Derive: public Base { public: Derive(): Base(0){} Derive(int x) { d=x; } void setvalue(int i) { data=i; } private: d; }A.1B.2C.3D.4
考题
有以下程序:include using namespace std;class Base{public:Base(){}virtual void w
有以下程序: #include <iostream> using namespace std; class Base { public: Base(){} virtual void who() { cout<<"Base Class"<<end1; } ~Base(){} }; class Derivel : public Base { public: void who() { cout<<"Derivel Class"<<end1; } }; class Derive2 : public Base { public: void who () { cout<<"Derive2 Class"<<end1; } }; int main () { Base *p; Derivel obj1; Derive2 obj2; p=obj1; p=obj2; p->who ( ); return 0; } 执行程序后的输出结果是( )。A.Base ClassB.Derivel ClassC.Derive2 ClassD.程序编译时出错
考题
下列类的定义中,有( )处语法错误。 class Base { public: Base(){} Base(int i) { data=i; } private: int data; }; class Derive : public Base { public: Derive() : Base(O) {} Derive (int x) { d=x; } void setvalue(int i) { data=i; } private: int d; };A.1B.2C.3D.4
考题
下列类的定义中,有( )处语法错误。 class Base { publiC: Base(){} Base(int i) { data=i; } ptivate: int data; }; class DeriVe:public Base { public: Derive():Base(0){} Derive(int x) { d=x; } void setvalue(int i) { data=i; } private: d; };A.1B.2C.3D.4
热门标签
最新试卷