2、类class C1的说明如下,错误的语句是() class C1{ int a;//(a) void //(b) public: C1(int val);//(c) ~C1();//(d) };A.aB.bC.cD.d
2、类class C1的说明如下,错误的语句是() class C1{ int a;//(a) void //(b) public: C1(int val);//(c) ~C1();//(d) };
A.a
B.b
C.c
D.d
参考答案和解析
b
相关考题:
以下程序中,错误的行为①include ②class A③{④public:⑤int n=2;⑥A(int val){cout 以下程序中,错误的行为 ①#include < iostream.h > ②class A ③{ ④ public: ⑤ int n=2; ⑥ A(int val){cout << val<<end1;} ⑦ ~A( 0{}; ⑧}; ⑨void main( 0 ⑩{ (11) Aa(0); (12)A.⑤B.⑥C.⑦D.(11)
若类A和类B的定义如下:includeclass A{int i,j;public:int geti(){return i;}};class 若类A和类B的定义如下: #include<malloc.h> class A { int i,j; public: int geti() { return i; } }; class B:public A { int k; public: void make() { k=i*j; } }; 则上述定义中非法的表达式是( )。A.k=i*jB.int k;C.return i;D.void make();
( 31 )有如下程序:#includeiostreamusing namespace std;class C1{public:~C1(){ cout1; }};Class C2: public c1{public:~c2(){ cout2; }};int main(){C2 cb2;C1 *cb1;return 0;}运行时的输出结果是A ) 121B ) 21C ) 211D ) 12
以下程序中,错误的行为 ① include ② class A ③ { ④ public: ⑤ int n=2; ⑥ A(int va 以下程序中,错误的行为① #include<iostream.h>② class A③ {④ public:⑤ int n=2;⑥ A(int val) {cout < < val < < endl;}⑦ ~A( ) {};⑧ };⑨ void main( )⑩ {(11) A a (0) ;(12) }A.⑤B.⑥C.⑦D.⑩
以下程序中,错误的行是①#include②class A③{④ public:⑤ int n=2:⑥ A( int val){cout⑦ ~A(){};⑧};⑨void main()⑩{⑩ A a(0);⑩}A.⑤B.⑥C.⑦D.⑩
有如下程序: include using namespace std; class Part{ public: 有如下程序: #include <iostream> using namespace std; class Part{ public: Part(int x=0):val(x) { cout<<val; } ~Part() { cout<<val; } private: int val; }; class Whole { public: Whole(int x, int y, int z=0):p2(x),p1 (y),val(z) { cout<<val; } ~whole() { cout<<val; private: Part p1,p2; int val; }; int main() { Whole obj (1,2,3); return 0; }程序的输出结果是A.123321B.213312C.213D.123123
若类A和类B的定义如下class A{int i,j;public:int geti( ){return i;}};class B:public A{int k:public:void make( ){k=i*j;}};则上述定义中非法的语句是A.k=i*jB.int k;C.return i;D.void make()
有如下程序:includeusing namespace std;class MyClass{public:MyClass(int x):val(x 有如下程序: #include<iostream> using namespace std; class MyClass{ public: MyClass(int x):val(x){} void Print()const{cout<<“const:val=”<<<val<<‘\’;} void Print(){cout<<“val=”<<val<<‘t’;} private: int va1; }; int main(){ consA.val=10 const:val=20B.const:val=10 const:val=20C.const:val=10 val=20D.val=10 val=20
已知如下类定义: 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 ) { //... }
下面程序的输出结果是什么? class C1{ static int j=0; public void method(int a){ j++; } } class Test extends C1{ public int method(){ return j++; } public void result(){ method(j); System.out.println(j+method()); } public static void main(String args[]){ new TeA.0B.1C.2D.3
有如下程序:includeusing namespace std;class Part{public:Part(int x=0):val(x){co 有如下程序: #include<iostream> using namespace std; class Part{ public: Part(int x=0):val(x){cout ~Part( ){cout<<val;} pritave: int val; }; class Whole{ public: Whole(int x,int Y,int z=0):p2(x),p1(Y),val(z){cout<<val;} ~Whole( ){cout<<val;} pritave: Part p1,p2; int val; f; int main( ){ Whole obj(1,2,3); return 0; } 程序的输出结果是A.123321B.213312C.213D.123123
若类A和类B的定义如下: class A { int i,j; public: int geti () { return i; } }; class B : public A { int k; public: void make () { k=i*j; } }; 则上述定义中非法的语句是A.k=i*j;B.int k;C.return i;D.void make()
有如下程序:includeusing namespace std;class Part{public:Part(int x=0):val(x) {c 有如下程序: #include<iostream> using namespace std; class Part{ public: Part(int x=0):val(x) {cout<<val;} ~Part(){cout<<val;} private: int val; }; class Whole{ public: Whole(int x ,int y, int z=0):p2(x),p1(y),val(z){cout<<val;} ~Whole(){cout<<val;} private: Part p1,p2; int val; }; int main() Whole obj(1,2,3); return 0; } 程序的输出结果是( )。A.123321B.213312C.213D.123123
有类定义如下:class Type{public:Type(int i=0);Type operator-(int);friend Type operator+(Type,Type);private:int val;};若有对象定义Type c1;则下列语句序列中,错误的是A.Type(3)+c1;B.c1+Type(3);C.3-c1;D.c1-3;
有如下程序:#includeiostreamusing namespace std;class C1{public:-Cl()}cout1;}};class C2:public C1{public:~c2(){cout2;}};int main(){C2 cb2;C1*cbl:return 0;{运行时的输出结果是A.121B.21C.211 D、12
类的说明如下,请指出错误的地方 ______。 class Myclass { int a=111; public: Myclass(int x, int y); Myclass(int val); ~Myclass(); }A.int a=111;B.Myclass(Int x, int y);C.Myclass(int val);D.~Myclass();
x86,win32,vc++6,默认属性的控制台工程:class C1{public:virtual int sum(int i1, int i2){return (i1 + i2);}private:double m_var1;char m_var2;};char sz[] = "abcd";问题:sizeof(C1) = ?sizeof(sz) = ?
下列程序的输出结果是( )。 public class c3 { public static void main(String args[]) { char c1='B',c2='C'; if(c1+1<c2) ++C1; System.out.println(c1); } }A.BB.bC.CD.c
下面程序的结果是()。includeclass A{int a;public:A():a(1){}void showa(){cout 下面程序的结果是( )。 #include<iostream.h> class A { int a; public: A():a(1){} void showa(){cout<<a;} }; Class B { int a; public: B():a(2){} void showa(){cout<<a;} ); class C:public A,public B { int a; puA.1B.2C.3D.程序有错误
有如下程序:includeusing namespace std;class MyClass{public: MyClass(int x):val( 有如下程序: #include<iostream> using namespace std; class MyClass{ public: MyClass(int x):val(x) {} void Print() const {cout<<"const:val="<<val<<'\t';} void Print() {cout<<"val="<<val<<'t';} private: int val; }; int main() const MyClass obj1(10); MyClass obi2(20); obj1.Print(); obj2.Print(); return 0; } 程序的输出结果是( )。A.val=10 const:val=20B.const:val=10 const:val=20C.const:val=10 val=20D.val=10 val=20
有如下程序:includeusing namespace std;class MyClass{public:MyClass(int x):val( 有如下程序: #include<iostreanl> using namespace std; class MyClass{ public: MyClass(int x):val(x){ } void Set(int x){val=x;} void Print( )eonst{eout<<"val="<<val<<'\t';} private: int val; }; int main( ){ eonst MyClass objl(10); MyClass obj2(20); objl.Print(); //语句1 obj2.Print( ); //语句2 objl.Set(20); //语句3 obj2.Set(30); //语句4 return 0; } 其主函数中错误的语句是A.语句1B.语句2C.语句3D.语句4
有如下程序:includeusing namespace std;class C1{public:~Cl( ){cout 有如下程序: #include<iostream> using namespace std; class C1{ public: ~Cl( ){cout<<1;} }; class C2:public C1{ public: ~C2( ){cout<<2;} }; int main( ){ C2 cb2; C1*cb1: return 0; } 程序的输出结果是A.121B.21C.211D.12
下列程序的输出结果是______。 public class Test10 public static void main(String[] args) { char c1='B',c2='c'; if(c1 + 1<c2 ) ++c1; System.out.println(c1); }A.BB.bC.CD.c
以下程序中,错误的行为是( )。 ①#includeiostream.h ②class A ③{ ④public: ⑤ int n=2; ⑥ A(int val){coutvalendl;} ⑦ -A{}; ⑧}; ⑨void main ⑩{ ? A a(0); ?}A.⑤B.⑥C.⑦D.?
以下程序中,错误的行为①include②class A③{④public:⑤int n=2;⑥A(int val){cout 以下程序中,错误的行为①#include<iostream.h> ②class A ③{ ④ public: ⑤ int n=2; ⑥ A(int val){cout<<val<<end1;} ⑦ ~A(){}; ⑧}; ⑨void main() ⑩{ (11) A a(0); (12)}A.⑤B.⑥C.⑦D.(11)
interface A { public int getValue() } class B implements A { public int getValue() { return 1; } } class C extends B { // insert code here } Which three code fragments, inserted individually at line 15, make use of polymorphism?()A、 public void add(C c) { c.getValue(); }B、 public void add(B b) { b.getValue(); }C、 public void add(A a) { a.getValue(); }D、 public void add(A a, B b) { a.getValue(); }E、 public void add(C c1, C c2) { c1.getValue(); }
多选题interface A { public int getValue() } class B implements A { public int getValue() { return 1; } } class C extends B { // insert code here } Which three code fragments, inserted individually at line 15, make use of polymorphism?()Apublic void add(C c) { c.getValue(); }Bpublic void add(B b) { b.getValue(); }Cpublic void add(A a) { a.getValue(); }Dpublic void add(A a, B b) { a.getValue(); }Epublic void add(C c1, C c2) { c1.getValue(); }