using namespace std; class Base { private: void fun1() { cout<
举一反三
- 有以下程序: #include <iostream> using namespace std; class Base{ public: Base(int x=0) {cout<<x;} }; class Derived : public Base{ public: Derived(int x=0) {cout<<x;} private: Base val; }; int main(){ Derived d(1); return 0; } 程序的输出结果是
- 以下程序的输出结果是 。#include<;iostream>;#include<;iomanip>;using namespace std;void main(){ int i; for (i=1;i>;=0;) cout<;<;i--;}
- 下列程序执行后的输出结果是______。 #include [iostream] using namespace std; class A { public: A( ) { cout << "A"; } }; class B { public: B( ) { cout << "B"; } }; class C : public A { private: B b; public: C( ) { cout << "C"; } }; void main ( ) { C obj; } A: CBA B: BAC C: ACB D: ABC
- 有如下程序: #include using namespace std; class AA{ public: AA(){ cout<<1; } AA(AA &a){ cout<<2; } }; void f1(AA a){} void f2(AA &a){} int main(){ AA aa; f1(aa); f2(aa); return 0; }运行这个程序的输出是 A: 1 B: 12 C: 122 D: 121
- 下面程序的运算结果是( )。 #include<iostream> using namespace std; class A { public: virtual void fun()=0; }; class B:public A } public: void fun() {cout<<"new file"<<" ";} }; class C:public A { public: void fun() { cout<<"open file"<<" ";} }; void main() { A a, * p; B b;C c; p=&c; p->fun(); p=&b; } A: new file open file B: new file new file C: 编译出错 D: open file new file
内容
- 0
有如下程序: #include<iostream> using namespace std; class A{ public: static int a; void init( ){a=l;} A(int a=2){init( );a++;} }; int A::a=0; A obj; int main( ){ cout<<obj.a; return 0; } 程序的输出结果是 A: 0 B: 1 C: 2 D: 3
- 1
有如下程序: #include<iostream> using namespace std; class A public: virtual void func1()cout<<"A1"; void func2()cout<<"A2"; ; class B:public A public: void func1()cout<<"B1"; void func2()cout<<"B2"; ; int main() A: A*p=new B; B: p->func1(); C: p->func2(); D: delete p; E: retum 0;执行这个程序的输出结果是______。A.B1B2 F: A1A2 G: B1A2 H: A1B2
- 2
在下列选项中,没有构成死循环的程序段是______。 A: B: include <;iostream>;using namespace std;void main( ){ int i=2020; while(1) { i=i%100+1;if(i>;100)break; }} C: D: include <;iostream>;using namespace std;void main( ){ for(;;);} E: F: include <;iostream>;using namespace std;void main( ){ int i=36; while(i); --i;} G: H: include <;iostream>;using namespace std;void main( ){int i =10000;do{ ++i;}while(i>;=1000);}
- 3
下面程序的输出结果是( )。 #include <iostream> using namespace std; class A { public: A( ) {cout<<"A";} } class B { public: B() {coat<<"B" ;} } class C: public A { public: B b; C() {cout<<"C";} } void mian(){ C c; } A: CBA B: ABC C: ACB D: BCA
- 4
如下程序的输出结果是 #include<iostream> using namespace std; class A public: A( )cout<<"A"; ; class Bpublic:B( )cout<<"B";; class C:public A B b; public: C( )cout<<"C"; ; int main( )C obj;return 0; A: CBA B: BAC C: ACB D: ABC