题库 题库

【填空题】

有如下程序:
#include<iostream>
using namespace std;
clsaa CA{
public:
CAD{cout<<A’;}
};
class CB ;private CA{
public;
CB(){cout<<B’;}
};
int main(){cout<<B’;}
};
int main(){
CA a;
CB b;
retum0;
}
这个程序的输出结果是 ______ 。

参考答案

查看答案

相关试题

单选题 使用输入输出操作符setw,可以控制 查看答案
单选题 有如下函数定义:
void func (int a,int&b) {a++; b++;}
若执行代码段:
intx=0 ,y=1
func(x,y);
则变量x和y值分别是
查看答案
单选题 下列叙述中正确的是 。 查看答案
单选题 下列叙述中正确的是 。 查看答案
单选题 下面程序中对一维坐标点类Point进行运算符重载
#include<iostream>
using namespace std;
class point {
public:
point (int vaI) {x=val;}
point& operator++(){x++;retum*this;}
print operator++(int) {point old=*this,++(*this);retum old;}
int GetX() const {retum x;}
private:
int x;
};
int main()
{
point a(10);
cout<<(++a).GetX();
cout<<a++.GetX();
retum();
}
编译和运行情况是
查看答案
单选题 有如下函数模板:
template <class T> T souare(T x) (retumx * x ;)
基中T是
查看答案
单选题 为了取代C中带参数的宏,在C++中使用 查看答案
单选题 在E-R图中,用来表示实体之间是联系的图形是 。 查看答案
单选题 对下列二叉树
  
进行前序遍历的结果是
查看答案
单选题 有如下程序段
inti =0, j=1;
int&r=i ; // ①
r =j; //②
int*p=&i ; //③
*p=&r ; //④
基中会产生编译错误的语句是
查看答案
单选题 下列运算符中,不能被重载的是 查看答案
单选题 下列关于派生类构造函数和析构函数的说法中,错误的是 查看答案
单选题 在语句cin>>data;中,cin是 查看答案
单选题 有如下程序:
#include<iostream>
using namespace std;
class A{
public
static int a;
void init(){a=1;}
A(int a=2) {init();a++;}
};
int A:;a=0
A obj;
Int main()
{
cout<<obj.a;
retum0;
}
运行时输出的结果是
查看答案
单选题 虚函数支持多态调用,一个基类的指针可以指向派生类的对象,而且通过这样的指针调用虚函数时,,被调用的是指针所指的实际对象的虚函数,而非虚函数不支持多态调用。有如下程序:
#include<iostream>
using namespace std;
class Base
{
public:
virtual void f(){cout<<”f0+”;}
void g() {cout<<”g0+”;}
};
class Derived:public Base
{
public:
void f() {cout<<”f+”;}
void g() {cout<<”g+”;}
};
int main()
{
Derived d;
Base*p=&d;
p->f(); p->g();
return 0:
}
运行时输出的结果是
查看答案
单选题 如果不使用多态机制,那么通过基类的指针虽然可以指向派生类对象,但是只能访问从基类继承的成员,有如下程序,没有使用多态机制。
#include<iostream>
using namespace std;
class Base{
int a,b;
public:
Bace(int x ,int y) { a=x; b=y;}
Void show(){ cout<<a<<’,’<<b<<endl;}
}
clsaa Derived:public Base {
int c ,d;
public:
Derived(int x,int y,int z,int m):Base(x,y){c=z; d=m;}
Void show(){ cout<<c<<’,’d<<endl;}
};
int main()
{
Base B1(50,50),*pb;
Derived DI(10,20,30,40);
Pb=&D1;
Pb->show();
Return 0;
}
运行时输出的结果是
查看答案
单选题 有如下程序::
#include<iostream>
using namespace std:
class Sample
{
friend long fun (Sample s);
public:
Sample (long a ){x=a;}
Private:
long x;
};
long fun (Sample s)
{
if(s.x<2)retum 1;
retum s.x*fun(Sample(s.x-a));
}
int main()
{
int sum=0
for(int i =0; i <6; i ++) { sum+=fun(Sample( i );) }
cout<<sum;
retum 0;
}
运行时输出的结果是
查看答案
单选题 下列函数模板的定义中,合法的是 查看答案
单选题 下列对列的叙述正确的是 。 查看答案
单选题 执行下列语句段后,输出字符“*”的个数是
for(int i =50;I>1;— i )cout<<”*”
查看答案