单选题有如下程序:
#include<iostream>
using namespace std;
class Point {
public:
static int number;
public:
Point() {number++;}
~Point() {number --;}
};
int Point::number=0;
int main() {
Point *ptr;
Point A, B;
{
Point *ptr_point=new Point[3];
ptr=ptr_point;
}
Point C;
cout<<Point::number<<endl;
delete[]ptr;
return 0;
}
执行这个程序的输出结果是______。
单选题阅读以下程序: #include<iostream.h> void maim() { static int a[][2]={5,3,1,2}; int i,j,s1=0; for(i=0;i<2;i.++) fort(j=0;j<2.j++) { if(i==j) s1=s1+a[i][j]; } cout<<s1<<endl; } 则该程序的输出结果为( )。
单选题下列关于内联函数的叙述中,错误的是______。
单选题下列语句中错误的是( )。
单选题设二叉树如下:则前序序列为
单选题下面程序的运行结果是( )。
#include
using namespace std;
class TestClass
{static intn;
public:
TestClass()
{
n++:
}
static int test()
{
for(int i=0;i<4;i++)
n++:
return n:
}
};
int TestClass::n=0:
int main()
{cout<
单选题有如下函数模板定义: temp1ate<c1ass T> T func(T x,T y){return x*x+y*y;} 在下列对func的调用中,错误的是( )。
单选题下列程序中对一维坐标点类Point进行运算符重载:
class Point
{
public:
Point(int val){x=val;}
Point
return *this;
}
Point operator++(int)
{
Point old=*this;
++(*this);
return old;
}
int GetX()const{return x;}
private:
int x;
};
int main()
{
Point a(10);
cout<<(++a).GetX();
cout<<a++.GetX();
return 0;
}
编译和运行情况是______。
单选题for(int x=0,y=0;!xy++)语句执行循环的次数是( )。 A.0 B.5 C.6 D.无数次
单选题有如下程序: #qnclude<iostream> #include<iomanip> using namespace std; class CSum { int x,y; public: CSum(int x0,int y0):x(xo),y(yo){} friend ostream return os; } }; int main(){ CSum y(3.5}; cout<<setfill('*')<<8 cout<<y; return0; } 执行上面程序的输出是
单选题下列关于类模板的模板参数的叙述中,错误的是( )。
单选题有如下程序:
#include<iostream>
using namespace std;
class Sample{
public:
Sample(){}
~Sample(){cout<<"*";}
};
int main(){
Sample temp[2],*pTemp[2];
return 0;
}
执行这个程序输出星号(*)的个数为______。
单选题类MyClass的定义如下: class MyClass
{ public: MyClass(){value=0;}
SetVariable(int i){value=i;} private: int
value; }; 则对下列语句序列正确的描述是{{U}}
{{/U}}。 MyClass*P,my;p=
A. 语句p=&my;是把对象my赋值给指针变量P
B. 语句MyClass*p,my;会调用两次类MyClass的构造函数
C. 对语句*P. SetVariable(5)的调用是正确的
D. 语句p->SetVariable(5)与语句my.SetVariable(5)等价
单选题下面程序的输出结果是( )。 #include<iostream> using namespace std; void swap(int x[2]) { int t; t=x[0]; x[0]=x[1]; x[1]=t; } void main() { int a[2]={4,8}; swap(a); cout<<a[0]<<" "<<a[1]; }
单选题请指出在顺序表{2、5、7、10、14、15、18、23、35、41、52}中,用二分法查找关键码12需做( )次关键码比较。
单选题有如下程序: #include <iostream> void fun(intx=y;y=t;} int main () { int a[2]={23,42}; fun(a[1],a[0]); std::cout<<a[0]<<","<<a[1]<<std::endl; return 0; } 执行后的输出结果是
单选题下列选项中不合法的标识符是( )。
单选题下列给字符数组进行初始化中,正确的是( )。 A) char sl[ ]="12345abcd"; B) char s2[3]="xyz"; C) char s3[][3]= 'a', 'x', 'y' ; D) char s4[2[3]="xyz","mnp";
单选题下列关于动态联编的描述中,错误的是( )。
单选题虚函数支持多态调用,一个基类的指针可以指向派生类的对象,而且通过这样的指针调用虚函数时,被调用的是指针所指的实际对象的虚函数。而非虚函数不支持多态调用。有如下程序; #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= P->f(); P->g(); return 0; }运行时输出的结果是