-
有如下程序:include<iostream>using 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(){ cons
A.val=10 const:val=20
B.const:val=10 const:val=20
C.const:val=10 val=20
D.val=10 val=20
-
有如下程序:include<iostream>using namespace std;class sample{private:int x,y;public:sampl
有如下程序: include<iostream> using namespace std; class sample { private: int x,y; public: sample(int i,int j) { x=i; y=j; } void disp() { cout<<"disp1"<<endl; } void disp()const { cout<<"disp2"<<endl; } }; int main() { const sample a(1,2); a.disp(); return 0; } 该程序运行后的输出结果是()。
A.disp1
B.disp2
C.disp1 disp2
D.程序编译时出错
-
有如下程序:include<iostream)using namespace std;class AA{int n;public:AA(int k):n(k){}int
有如下程序: include<iostream) using namespace std; class AA{ int n; public: AA(int k):n(k){} int get(){return n;} int get()const{return n+1;} }; int main() { AA a(5); const AA b(6); COUt<<A.get()<<b.get(); return 0
A.55
B.57
C.75
D.77
-
有如下程序:include <iostream>using namespace std;class AA {int n;public:AA(int k):n(k) {
有如下程序: include <iostream> using namespace std; class AA { int n; public: AA(int k):n(k) { } int get() {return n;} int get()const {retnm n+1; } int main() { AA a(5); const AA b(6); cout <<a.get()<<b.get(); return 0; }执行后的输出结果是______ 。
A.55
B.57
C.75
D.77
-
有如下程序:include<iostream>using namespace std;int main(){int *p;*p=9;cout<<"The value a
有如下程序: include<iostream> using namespace std; int main() { int *p; *p=9; cout<<"The value at p:"<<*p; return 0; } 编译运行程序将出现的情况是()。
A.编译时出现语法错误,不能生成可执行文件
B.运行时一定输出:The value at p:9
C.运行时一定输出:The value at p:*9
D.运行时有可能出错
-
有如下程序:include <iostream>using namespace std;int main(){int*P;*P=9;cout<<"The value
有如下程序: include <iostream> using namespace std; int main(){ int*P; *P=9; cout<<"The value at P:"<<*P: return 0; } 编译运行程序将出现的情况是
A.编译时出现语法错误,不能生成可执行文件
B.运行时一定输出:The value at P:9
C.运行时一定输出:The value at P:*9
D.运行时有可能出错
-
有如下程序:include<iostream.h>long fib(int n){if(n>2)return(fib(n-1)+fib(n-2)); else retu
有如下程序: include<iostream.h> long fib(int n) { if(n>2)return(fib(n-1)+fib(n-2)); else return(2);} void main() {cout<<fib(3);} 该程序的输出结果是
A.2
B.4
C.6
D.8
-
有如下程序: include<iostream> usingnamespacestd; classA{ public: A(inti):rl(i){)
有如下程序: include<iostream> usingnamespacestd; classA{ public: A(inti):rl(i){) voidprint(){cout<<E<<r1<<-;) voidprint()const{cout<<C<<r1*r1<<-;} private: intr1: }; intmain(){ Aal(2);constAa2(4);, al.print();a2.print(); return0; } 运行时的输出结果是()。
A.运行时出错
B.E2一C16一
C.C4一Cl6一
D.E2一E4—
-
有如下程序:include<iostream>using namespace std;class DA{int k;public:DA(int x=1):k(x){}~
有如下程序: include<iostream> using namespace std; class DA{ int k; public: DA(int x=1):k(x){} ~DA(){cout<<k;} }; int main(){ DAd[]={DA(3),DA(3),DA(3)}; DA*p=new DA[2]; delete[]p; return(); } 这个程序的输出结果是()。
A.111
B.333
C.11333
D.11133
-
有如下程序:include<iostream>using namespace std;class A {public:A(){cout<<"A";}};classB{p
有如下程序: include<iostream> using namespace std; class A { public: A(){cout<<"A";} }; classB{public:B(){cout<<"B";}} classC:public A{ B b; public: C(){cout<<"C";} }; int main(){ C obj; return 0;} 执行后的输出结果是()。
A.CBA
B.BAC
C.ACB
D.ABC
-
有如下程序:include<iostream>using namespace std;long fun(int n){if(n>2)return(fun(n-1)+fu
有如下程序: include<iostream> using namespace std; long fun(int n) { if(n>2) return(fun(n-1)+fun (n-2)); else return 2; } int main() { cout<<fun(3)<<end1; return 0; } 则该程序的输出结果应该是 ()。
A.2
B.3
C.4
D.5
-
有如下程序:include <iostream>include<iomanip>using namespace std;int main(){cout.fill('*
有如下程序:include <iostream>include<iomanip>using namespace std;int main(){ cout.fill('*'); cout.width(6); cout.fill(''); cout<<123<<end1; return 0;}执行后的输出结果是()。
A.123
B.123
C.***123
D.123***
-
有如下程序: include<iostream> usingnamespacestd; classAA{ public; AA(){cOUt<<1;)
}; classBB:publicAA{ intk; public: BB():k(0){tout<<12;} BB(intn):k(n)(cout<<3;) }; intmain(){ BBb(4),c; return0; } 运行时的输出结果是().
A.1312
B.132
C.32
D.1412
-
有如下程序include<iostream.h>int func(int a,int b){ return(a+b) ;}void main(){ int x=2,y
有如下程序 include<iostream.h> int func(int a,int b) { return(a+b) ;} void main() { int x=2,y=5,z=8, r; r=func (func(x,y),z); cout << r; } 该程序的输出的结果是
A.12
B.13
C.14
D.15
-
有如下程序:include<iostream>using namespace std;class BASE{public:~BASE(){cout<<"BASE";}
有如下程序: include<iostream> using namespace std; class BASE{ public: ~BASE(){cout<<"BASE";} }; class DERIVED:public BASE{ public: ~DERIVED(){cout<<"DERIVED";} }; int main(){DERIVED x;return 0;} 程序的输出结果是
A.BASE
B.DERIVED
C.BASEDERIVED
D.DERIVEDBASE
-
有如下程序:include<iostream>using namespace std;class GA{public:virtual int f(){return 1
有如下程序: include<iostream> using namespace std; class GA{ public: virtual int f(){return 1;} }; class GB:public GA{ public: virtual int f(){return 2;} }; void show(GA g){eout<<g.f();} void display(GA&g){cout<<g.f();} int main(){ GA a;show(A) ;display(A) ; GB b;show(B) ;display(B) ; return 0; } 程序的输出结果是
A.1111
B.1211
C.1112
D.1212
-
有如下程序: include<iostream>using()
A.232
B.231
C.222
D.221
-
有如下程序:include<iostream>using namespace std;class A{public:A(){cout<<"A";}~A(){cout<<
有如下程序: include<iostream> using namespace std; class A { public: A(){cout<<"A";} ~A(){cout<<"~A";} }; class B:public A { A*p; public: B(){cout<<"B";p=new A;} ~B(){cout<<"~B";delete p;} }; int main() { B obj; return 0; } 执行这个程序的输出结果是()。
A.BAA~A~B~A
B.ABA~B~A~A
C.BAA~B~A~A
D.ABA~A~B~A
-
有如下程序include<iostream>using namespace std;class base{public:virtual void f1(){cout<<
有如下程序 include<iostream> using namespace std; class base { public: virtual void f1() { cout<<"F1Base"; } virtual void f2() { cout<<"F2Base"; } }; class derive:public base { void f1() { cout<<"F1 Derive"; } void f2(int x) { cout<<"F2 Derive"; } }; int main() { base obj1,*p; derive obj2; p=& obj2; p->f1(); p->f2(); return (); ) 执行后的输出结果是()。
A.F1Derive F2Base
B.F1Derive F2Derive
C.F1Base F2Base
D.F1Base F2Derive
-
有如下程序: include<iostream> usingnamespacestd; classTest { public: Test(){n+=2;} ~Test(){n-=3;} staticintgetNum(){returnn;} private: staticintn; }; intTest::n=1; intmain() { Test*p=neWTest; deletep;
cout<<"n="<<Test::getNum()<<endl; return0; } 执行该程序的输出结果是()。
A.n=0
B.n=1
C.n=2
D.n=3
-
若有如下程序:include<iostream>using namespace std;class TestClass{public:void who() {cout
若有如下程序: include<iostream> using namespace std; class TestClass { public: void who() {cout<<"TestClass"<<endl;} }; class TestClass1:public TestClass { public: void who(){cout<<"TestClass1"<<endl;} }; int main() { TestClass *p; TcstClass1 obj1; p=&obj1; p->who(); return 0; } 则该程序运行后的输出结果是()。
A.TestClass1
B.TestClass
C.0
D.无输出
-
有如下程序:include <iostream>using namespace std;class BASE{public:~BASE(){cout<<"BASE";}
有如下程序:include <iostream>using namespace std;class BASE{public: ~BASE(){cout<<"BASE";}};class DERIVED: public BASE{public: ~DERIVED(){ cout<<"DERIVED"; }int main() { DERIVED x; return 0; }执行后的输出结果是()。
A.BASE
B.DERIVED
C.BASEDERIVED
D.DERIVEDBASE
-
有如下程序:include<iostream>using namespace std;class Test{public:Test(){n+=2;}~Test(){n-
有如下程序: include<iostream> using namespace std; class Test{ public: Test() {n+=2;} ~Test() {n-=3;} static int getNum(){return n;} private: static int n; }; int Test::n=1; int main() { Test* p=new Test; delete p; cout<<"n="<<Test::getNum()<<endl; return0; } 执行后的输出结果是()。
A.n=0
B.n=1
C.n=2
D.n=3
-
有如下程序:include<iostream>using namespace std;int fun(int a, int b){return(a*b++);}vo
有如下程序: include<iostream> using namespace std; int fun(int a, int b) {return(a*b++);} void main() { int x=3,y=4,z=5,r; r=fun (fun (x,y),z); cout<<r>>endl; cout<<x<<endl; cout<<y<<endl; } 该程序的输出的结果是()。
A.85 3 4
B.60 3 4
C.126 4 5
D.85 4 5
-
有如下程序: include<iostream> usingnamespacestd; classAA{ intn; public: AA(intk
有如下程序: include<iostream> usingnamespacestd; classAA{ intn; public: AA(intk):n(k){} intget(){returnn;} intget()const{returnn+1;} }; intmain() { AAa(5); constAAb(6); cout<<a.get()<<b.get(); return0; } 执行后的输出结果是()。
A.55
B.57
C.75
D.77