在一个C++程序中,每个变量都必须遵循 【6】 的原则。

多态性分为两类:编译时的多态性和 【7】

语句cout<<setprecision (3)<<3.1415926<<end1;的输出为 【8】

非成员函数应声明为类的 【9】 函数才能访问这个类的private 成员。

下面程序的运行结果为 【10】
#include<iostream.h>
void main( )char a=’3’;
switch(a)case’3’: cout<<"3";
case’2’: cout<<"2"; break;
default: cout<<" 1";

下列程序的输出结果为
Object id=0
Object id=1
请将程序补充完整。
#include <iostream>
using namespace std;
class Pointpublic:
Point(int xx=0,int yy=0) X=xx; Y=yy; countP++;
~Point( )countP--;
int GetX( )retum X;
int GetY( )return Y;
static void GetC( ) cout<<"Object id="<<countP<<end1;
private:
int X,Y;
static int countP;
;
【11】 //静态数据成员的初始化
int main( ) Point:: GetC( );
Point A(4,5);
A. GetC( );
retum 0;

int Point::countP=0;

以下程序执行后的输出结果是 【12】
#include<iostream.h>
main( )int i, m=0,n=0,k=0;
for(i=9;i<= 11 ;i++)
switch(i/10)case 0: m++; n++; break;
case 10: n++; break;
default: k++; n++;cout<<m<<n<<k;

下列程序的输出结果是 【13】
#include <iostream>
using namespace std;
int main( ) int data=1;
int &r = data;
data+=5;
r+=5;
cout<<data<<end1;
return 0;

分析以下程序的执行结果 【14】
#include<iostream.h>
class Sampleint x, y;
public:
Sample( ) x=y=0;
Sample(int a, int b) x=a; y=b;
~Sample( )if(x==y)
cout<<"x=y"<<end1;
else
cout<<"x!=y" <<end1;void disp( )cout<<"x="<<x<<",y="<<y<<end1;;
void main( )Sample s 1 (2,3);
s1. disp( );

x=B,y=C
x!=y

在析构函数中调用虚函数时,采用 【15】 联编。

微信扫码获取答案解析
下载APP查看答案解析