C++试卷
第501题
下列关于虚函数的说明中,正确的是()。
第502题
有如下程序,运行此程序,屏幕上将显示输出()。
#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 *p=new B;
p->func1();
p->func2();
return 0;
}
第503题
有如下程序,运行时输出的结果是()。
#include<iostream>
using namespace std;
class Base{
int a,b;
public:
Base(int x, int y){a=x; b=y;}
void show() {cout<<a<<','<<b<<endl;}
};
class 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 D1(10,20,30,40);
pb=&D1;
pb->show();
return 0;
}
第504题
有如下程序,运行时输出的结果是()。
#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;
}
第505题
有如下程序,运行时的输出结果是()。
#include <iostream> using namespace std;
class Publication{ //出版物类 char name[30];
public: Publication(char *name="未知名称"){ strcpy(this->name,name);
} const char* getName()const{
return name; }
virtual const char* getType()const{ return "未知类型";} };
class Book:
public Publication{ //书类 public: Book(char *name):
Publication(name){}
virtual const char* getType()const{ return "书";} };
void showPublication( Publication &p){ cout<<p.getType()<<":"<<p.getName()<<endl; }
int main(){ Book book("精彩人生");
showPublication(book);
return 0; }
第506题
有如下程序,运行时的输出结果是()。
#include<iostream> using namespace std; class B{
public: B(int xx):x(xx){++count;x+=10;}
virtual void show() const {cout<<count<<'_'<<x<<endl;}
protected: static int count; private: int x; }; class D:
public B{ public: D(int xx,int yy):B(xx),y(yy){++count;y+=100;}
virtual void show() const {cout<<count<<'_'<<y<<endl;}
private: int y; };
int B::count=0; int main(){ B *ptr=new D(10,20); ptr->show(); delete ptr; return 0; }
第507题
有如下程序,下列叙述中正确的是()。
#include<iostream> using namespace std;
class Instrument{ public: virtual void Display()=0; };
class Piano : public Instrument{ public: void Display(){/*函数体程序略*/} };
int main(){ Instrument s; Instrument *p=0; //... return 0; }
第508题
有如下程序,若程序运行时输出结果是“文学”,则划线处缺失的语句是()。
#include
using namespace std;
class Book{
public:
Book(char*t="") {strcpy(title,t);}
private:
char title[40];
};
class Novel: public Book{
public:
Novel(chart=""): Book(t){}
charCategory() const { return "文学";}
};
int main(){
Book pb;
pb=new Novel();
cout<Category();
return 0;
}
第509题
下列叙述中正确的是
第510题
一棵二叉树有25个结点,其中5个是叶子结点,则度为1的结点数为
第511题
在下列模式中,能够给出数据库物理存储结构与物理存取方法的是
第512题
在满足实体完整性约束的条件下
第513题
有三个关系R、S和T,则由关系R和S得到关系T的操作是
关系 R:
| A | B | C |
| a | 1 | 2 |
| b | 2 | 1 |
| c | 3 | 1 |
关系 S:
| A | B | C |
| a | 1 | 2 |
| b | 2 | 1 |
关系 T:
| A | B | C |
| c | 3 | 1 |
第514题
软件生命周期的活动中不包括
第515题
下面不属于需求分析阶段任务的是
第516题
在黑盒测试方法中,设计测试用例的主要根据是
第517题
在软件设计中不使用的工具是
第518题
若一个函数的原型为“int Xfun(int xint &ychar z);”,则该函数的返回值类型为
第519题
若AA为一个类,a为该类的私有整型数据成员,getA()为该类的一个非静态公有成员函数,功能是返回a的值。如果x为该类的一个对象,要在类外访问x对象中a的正确的访问格式为
第520题
当派生类继承一个基类时,默认的继承方式为