有如下程序: #include
using namespace std; class Base { private: void fun1() { cout<
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