有以下程序:
class Date
public:
Date(int y, int m, int d);
year = y;
month = m;
day = d;
Date(int y = 2000)
year = y;
month = 10;
day = 1;
Date(Date &d)
year = d.year;
month = d.month;
day = a.day;
void print( )
cout<<year<<"."<<month<<"."<<day<<end1;
private:
int year, month,day;
;
Date fun(Date d)
Date temp;
temp = d;
return temp;
int main( )
Date date 1 (2000,1,1),date2(0,0,0);
Date date3(date 1);
date2 = fun(date3);
return 0;
程序执行时,Date 类的拷贝构造函数被调用的次数是
A:2 B:3 C:4 D:5
有以下程序
#include <iostream>
#include <string>
using namespace std;
class base
private:
char baseName[10];
public:
base( )
strcpy(baseName,"Base");
virtual char *myName( )
return baseName;
char *className( )
Return baseName;
;
class Derived: public base
private:
char derivedName[10];
public:
Derived( )
strcpy(derivedName,"Derived" );
char *myName( )
return derivedName;
char *className( )
return derivedName;
;
void showPtr(base &p)
cout<<p.myName( )<<" "<<p.className( );
int main( )
base bb;
Derived dd;
showPtr(dd);
return 0;
运行后的输出结果为
A:Derived Base B:Base Base C:Derived Derived D:Base Derived
在深度为5的完全二叉树中,度为2的结点数最多为 【1】 。
在面向对象方法中,允许作用于某个对象上的操作称为 【2】 。
软件生命周期包括8个阶段。为了使各时期的任务更明确,又可分为3个时期:软件定义期、软件开发期、软件维护期。编码和测试属于 【3】 期。
在关系运算中, 【4】 运算是对两个具有公共属性的关系所进行的运算。
实体之间的联系可以归结为一对一的联系,一对多的联系与多对多的联系。如果一个学校有许多学生,而一个学生只归属于一个学校,则实体集学校与实体集学生之间的联系属于 【5】 的联系。
写出执行完下列代码段之后指定变量的值:
bool x=true,y=false,z=false;
x=x&&y‖z;
y=x‖y&&z;
z=!(x!=y)‖(y==z);
则x=false,y=false,z= 【6】 。
多态性分为两类:编译时的多态性和 【7】 。
非成员函数只有在声明为类的 【8】 才能访问这个类的所有private成员。