单选题下列程序的运行结果是 #inClude<iostream.h> roid fun(int *a,int * b) { int * k; k=a;a=b;b=k;} void main( ) { int a=2004,b=9,* x=&a,* y=&b; fun(x,y); cout < < a < <" " < < b < < end1;}
单选题下列运算符中不能在C++中重载的是
A. ?:
B. +
C. -
D. <=
单选题下列有关内联函数的叙述中,正确的是______。
单选题在下面的运算符重载函数的原型中,错误的是( )。
单选题类K是类Y及类Z的虚基类,类D是类Y及类Z的多继承派生类,则在构造类D的对象时,类X的构造函数将被调用 ______。
单选题已知函数f的原型是void f(int *a,long 下列调用语句中正确的是( )。
单选题设R是一个2元关系,有3个元组,S是一个3元关系,有4个元组。如T=R×S,则T的元组为( )个。
单选题Sample是一个类,执行下面语句后,调用Sample类的构造函数的次数是( )。 Sample a[2],*p=new Sample;
单选题有如下函数模板定义: template<typename T1,Typename T2> T1 Fun(T2 n){ return n*5.0;} 若要求以int型数据9作为函数实参调用该模板,并返回一个double型数据,则该调用应表示为( )。
单选题有如下程序:
#included
usingnamespacestd;
classA{
public:
virtualvoidfuncl(){coutfunc1();
P->func2();
return0;}
执行该程序,屏幕上将显示输出( )。
单选题有如下程序:
#included
usingnamespqcestd;
classTestClass
{
private;
charC;
public;
TestClass(charn):c(n){}
~TestClass()
{
cout< }
};
classTestClassl:publicTestClass
{
private:
charC;
public:
TestClassl(charn):TestClass(n+1),c(n){}~TestClassl()
{
cout< }
};
intmain()
{
TestClasslobj(’X’);
return0;
}
执行上面的程序将输出( )。
单选题有如下程序: #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; return s.x * fun(Sample(s.x一1)); } int main() { int sum=0; for(int i=0;i<6;i++) {sum+=fun(Sample(i));} cout<<sum; return 0; } 执行这个程序的输出结果是( )。
单选题已知Value是一个类,value是Value的一个对象。下列以非成员函数形式重载的运算符函数原型中,正确的是( )。
单选题设int x[ ]={2,4,6,8},y,*p=&x[1];则执行语句y=(*--p)++;后数组元素x[0]的值为
______。
A. 2
B. 3
C. 4
D. 5
单选题下面程序的运行结果是
#include<iostream.h>
void fun(int * a,int * b)
{
int x= * a;
* a= * b; * b=X;
cout < < * a < < * b < <" ";
}
void main( )
{
int x=1,y=2;
fun(
cout < < X < < y < < endl;
}
A) 12 12 B) 12 21 C) 21 12 D) 21 21
单选题为完成下面的程序,在画线处应填入的语句是______。
#included<iostream>
using namespace std;
class Base
{
int x;
public:
Base(int i){x=i;}
~Base(){}
};
class Derived:public Base
{
public:
______//完成类Derived构造函数的定义
};
int main()
{
Derived obj(2);
return 0;
}
单选题有如下类定义: c1ass AA { int a; public: int getRef()const{ retum } // ① int getValue()const{ retuma;} // ② void set(int n)const{ a=n;} // ③ friend void show(AA aa)const{ cout<<a;}// ④ }; 其中的四个函数定义中正确的是( )。
单选题下面关于虚函数的描述,错误的是( )。
单选题有如下类定义: class XX{ int xdata; public; XX(int n=0):xdata(n){} }; class YY:public XX{ int ydata; public; YY(int m=0,int n=0):XX(m),ydata(n){} }; YY类的对象包含的数据成员的个数是( )。
单选题若执行下面的程序时,从键盘上输入5和2,则输出结果是______。
# include<iostream.h>
void main()
{ int a,b,k;
cin>>a>>b;
k=a;
if(a<b)
k=a%b;
else
k=b%a;
cout<<k<<endl;}
