网友您好, 请在下方输入框内输入要搜索的题目:

题目内容 (请给出正确答案)

有如下类定义: class Fun { public: Fun(int v):value(v){}//① ~Fun(){}//② private: Fun{},//③ int value=0;//④ }; 其中存在语法错误的行是( )。

A.①

B.②

C.③

D.④


参考答案

更多 “ 有如下类定义: class Fun { public: Fun(int v):value(v){}//① ~Fun(){}//② private: Fun{},//③ int value=0;//④ }; 其中存在语法错误的行是( )。A.①B.②C.③D.④ ” 相关考题
考题 ● 函数fun1()、fun2()的定义如下所示,已知调用fun1 时传递给形参x的值是-5,若以引用调用(call by reference)的方式调用fun2,则函数fun1的返回值为 (33) ;若以值调用(call by value)的方式调用fun2,则函数fun1的返回值为 (34) 。fun1(int x) fun2(int x) int a=x-1;x = fun2(a);return a-x; x=x+10;return 3*x;(33)A. -18 B. -11 C. -8 D. 0(34)A. -18 B. -11 C. -8 D. 0

考题 有如下程序#includeusing namespace std;int i=1;class Fun{public;static int i;int value(){return i-1}int value ()const{return i+1;}};int Fun;;i=2;int main(){int i=3;Fun Fun1const Fun fun2;return 0;}若程序的输出结果是:123则程序中下划线处遗漏的语句是______。A.coutB.coutC.coutD.cout

考题 有如下类定义:class Foo{public:Foo(int v):value(v){} // ①~Foo(){} // ②private:Foo(){} // ③int value = 0; // ④};其中存在语法错误的行是A . ①B . ②C . ③D . ④

考题 有如下程序:#includeusing namespace std;class Base{private:void funl() const{cout"funl";}protected:void fun2() const{cout"fun2";}public:void fun3() const{cout"fun3";}};class Derived:protected Base{public:void fun4() const{cout"fun4";}};int main(){Derived obj;obj.funl(); // ①obj.fun2(); // ②obj.fun3(); // ③obj.fun4(); // ④return 0;}其中有语法错误的语句是A . ①②③④B . ①②③C . ②③④D . ①④

考题 ( 28 ) 有如下程序#includeusing namespace std;int i=1;class Fun{public:static int i;int value( ){ return i-1;}int value( )const{ return i+1;}};int Fun::i=2;int main( ){int i=3;Fun fun1;const Fun fun2;____________return 0;}若程序的输出结果是 :123则程序中下划线处遗漏的语句是A ) coutFun::iB ) coutFun::ifun1.value()C ) coutFun::i;D ) cout

考题 有如下程序 include using namespace std; int i=1; class Fun { 有如下程序 #include <iostream> using namespace std; int i=1; class Fun { public: static int i; int value( ){ return i-l;} int value( )const { return i+1;} }; int Fun::i=2; int main( ){ int i=3; Fun funl; const Fun fun2; ___________ return 0; } 若程序的输出结果是: 123 则程序中下划线处遗漏的语句是A.cout<<funl.value( )<<Fun::i<<fun2.value( );B.cout<<Fun::i<<funl.value()<<fun2.value( );C.cout<<funl.value( )<<fun2.value( )<<Fun::i;D.cout<<fun2.value( )<<Fun::i<<fun1.value( );

考题 下列程序段中包含4个函数,其中具有隐含this指针的是( )。 int funl(); class Test{ public: int fun2(); friend int fun3(); static int fun4(); };A.fun1B.fun2C.fun3D.fun4

考题 有如下程序 include using namespace std;int i=1;class Fun {public:static int i;i 有如下程序 #include <iostream>using namespace std;int i=1;class Fun {public:static int i;int value(){ return i-1;}int value()const{ return i+1;}};int Fun:: i=2;int main() {int i=3;Fun fun1;const Fun fun2;______________________return ();}若程序的输出结果是:123A.cout<<fun1.value()<<Fun:: i<<fun2.value();B.cout<<Fun::i<<fun1.value()<<fun2.value();C.cout<<fun1. value()<<fun2.value()<<Fun:: i;D.cout<<fun2.value()<<Fun:: i<<fun 1.value();

考题 下列程序的运行结果为【 】。include class myclass{private: int a, b, c; public: v 下列程序的运行结果为【 】。include <iostream. h>class myclass{private:int a, b, c;public:void fun(){int a;a=10;this->,a=5;b=6;this->c=7;cout<<"a="<<a<<",this->a="<<this->a<<endl;}};void main(){myclass obj1;obj1.fun()}

考题 已知如下类定义: class Base { public Base (){ //... } public Base ( int m ){ //... } protected void fun( int n ){ //... } } public class Child extends Base{ // member methods } 如下哪句可以正确地加入子类中?() A.private void fun( int n ){ //...}B.void fun ( int n ){ //... }C.protected void fun ( int n ) { //... }D.public void fun ( int n ) { //... }

考题 对下面程序描述正确的是()。 include using namespace std; class A { private:int 对下面程序描述正确的是( )。 #include < iostream > using namespace std; class A { private: int i; public: class B { private: int j; protected: int k; int fun1 ( ); } MyB; int fun2 ( ); }A.定义类B的对象的语句是: A::B b;B.类A的成员函数fun2()可以用MyB.j的方式访问类B的私有成员j。C.类A的成员函数fun2()可以用MyB.k的方式访问类B的保护成员k。D.类B的成员函数fun1()可以直接访问类A的私有成员i。

考题 包容类Contain和内嵌类Embed定义如下:include class Contain{private:int x;protec 包容类Contain和内嵌类Embed定义如下: #include <iostream.h> class Contain { private: int x; protected: int z; public: class Embed { private: int y; public: Embed(){y=100;} int Embed_Fun(); }MyEmbed; int Contain_Fun(); }; 对上面的定义,正确的描述是( )。A.定义类Embed对象的语句是:Contain::Embed embed;B.类Contain的成员函数Contain_Fun()中可以用MyEmbed.y的方式访问类Embed的私有成员yC.类Embed的成员函数Embed_Fun()中可以直接访问类Contain和的私有成员xD.类Embed的成员函数Embed_Fun()中可以直接访问类Contain的保护成员z

考题 下列函数中,具有隐含的this指针的是( )。void fun1(); //①class MyClass{public:friend void fun2(); //②static int fun3(); //③int fun4(); //④}; A. ①B.②C.③D.④

考题 已知函数fun的原型是“void fun(int *x, int ”,变量v1、v2的定义是“int v1, v2; ”,则下列选项中,对函数fun调用正确的是( )。 A. fun(v1,B.fun(v1,v2);C.fun(D.fun(

考题 有如下程序:include using namespace std;class Base{ public: void fun() { cout 有如下程序: #include <iostream> using namespace std; class Base { public: void fun() { cout<<"Base::fun"<<endl; } }; class Derived : public Base { public: void fun() { ______ cout<<"Derived::fun"<<endl; } }; int main() { Derived d; d.fun(); return 0; } 已知其执行后的输出结果为: Base::fun Derived::fun 则程序中下划线处应填入的语句是( )。A.Base.fun();B.Base::fun();C.Base->fun();D.fun();

考题 有如下程序:includeusing namespace std;int i=1;class Fun{public:static int i;int 有如下程序: #include<iostream> using namespace std; int i=1; class Fun { public: static int i; int value(){return i-1;} int value()const{return i+1;} }; int Fun::i=2; int main() { int i=3; Fun fun 1; const Fun fun2; ______ return 0; } 若程序的输出结果是: 123 则程序中横线处的语句是( )。A.cout<<fun1.value()<<Fun::i<<fun2.value();B.cout<<Fun::i<<fun1.value()<<fun2.value();C.count<<fun.value()<<fun2.value()<<Fun::i;D.cout<<fun2.value()<<Fun::i<<fun1.value();

考题 包容类Contain和内嵌类Embed定义如下:includeclass Contain{private:int X;protect 包容类Contain和内嵌类Embed定义如下: #include<iostream.h> class Contain { private: int X; protected: int z; public: class Embed { private: int y; public: Embed(){y=100;} int Embed_Fun(); }MyEmbed; int Contain_Fun(A.定义类Embed对象的语句是:Contain? Embed embed;B.类Contain的成员函数Contain_Fun()中可以用MyEmbe D.y的方式访问类Embed的私有成员yC.类Embed的成员函数Embed_Fun()中可以直接访问Contain的私有成员xD.类Embed的成员函数Embed_Fun()中可以直接访问Contain的保护成员Z

考题 如在类中有如下函数定义 Void fun(int a,int b,int c=0);则下列调用中,正确的是( )。A.fun(1)B.fun(1,1)C.fun()D.fun(2,2,3,4)

考题 有如下类定义: classFoo { public:Foo(intv):value(v){}//① ~Foo(){}//② private: Foo(){}//③ intvalue=0;//④ }; 其中存在语法错误的行是( )。A.①B.②C.③D.④

考题 将下面程序补充完整。 include using namespace std; class Base{ public: 【 】fun(){r 将下面程序补充完整。include <iostream>using namespace std;class Base{public:【 】 fun(){return 0;} //声明虚函数};class Derived:public Base{public:x,y;void SetVal(int a,int b){}int fun(){return x+y;}};void 【 】 SetVal(int a,int b){x=a;y=b;} //类Derived成员函数void main(){Derived d;cout<<d.fun()<<endl;}

考题 有如下类定义: class Foo { public: Foo(int v) : value(v) { } // ① ~Foo() { } // ② private: Foo() { } // ③ int value = 0; // ④ }; 其中存在语法错误的行是( )。A.①B.②C.⑧D.④

考题 有如下类定义: class Foo { public: Foo(intv):value(v){} //① ~Foo(){} //② private: Foo(){} //③ int value=0; //④ }; 其中存在语法错误的行是( )。A.①B.②C.③D.④

考题 有如下程序: #includeiostream using namespace std; int i=1; class Fun{ public: static int i; int value{return i—l;} int valueconst{return i+1;} }; int Fun::i=2; int main{ int i=3; Fun funl; const Fun fun2: __________________ return 0; } 若程序的输出结果是: 123 则程序中下画线处遗漏的语句是( )。A.coutfunl.valueFun::ifun2.value;B.toutFun::ifunl.valuefun2.value;C.coutfunl.valuefuIl2.valueFun::i:D.eoutfun2.valueFun::ifunl.value;

考题 类 Contain 的定义如下: class Contain { private: int x; protected: int z; public: class Embed { private: int y; public: Embed ( ) { y=100; } int Embed_Fun(); }MyEmbed; int Contain_Fun(); }; 下列对上面定义的描述中,正确的是( )。A.定义类Embed对象的语句是:Contain::Embed Myobject;B.类Contain的成员函数Contain_Fun()中可以访问对象MyEmbed的私有成员yC.类Embed的成员函数Embed_Fun()中可以直接访问类Contain的所有成员D.类Embed的成员函数Embed_Fun()中只能直接访问类Contain的公有成员

考题 有如下程序: include using namespace std; class Base { private: 有如下程序: #include<iostream> using namespace std; class Base { private: void funl()const {cout<<"funl";} protected: void fun2() const{cout<<"fun2";} public; void fun3() const {cout<<"fun3";} }; class Derived:protected Base { public; void fun4() const {cout<<"fun4";} }; int main() { Derived obj; obj.funl(); //① obj.fun2(); //② obj.fun3(); //③ obj.fun4(): //④ return 0; } 其中有语法错误的语句是A.①②③④B.①②③C.②③④D.①④

考题 有如下程序: #includeiostream using namespace std; classBase{ public: void fun{ __________________ cout”Base::fun”endl;} }; class Derived:public Base{ public: voidfun{ cout”Derived::fun”endl: } }; int main{ Derived d; A fun; return 0; } 已知其执行后的输出结果为: Base::fun Derived::fun 则程序中下画线处应填入的语句是( )。A. Base.fun;B.Base::fun;C.Base—fun;D.fun;

考题 有如下程序: #includeiostream using namespace std; class Base { private: void funlconst{tout”funl”;} protected: void fun2const{tout”fun2”;} public: void fun3const{cout”fhll3”;} }; class Derived:protected Base { public: void fhn4const{cout”filn4”;} }; int main { Derived obj; obj.funl;//① obj.fun2;//② obj.furd;//③ obj.fun4;//④ return U: } 其中有语法错误的语句是( )。A.①②③④B.①②③C.②③④D.①④