单选题已知函数print()没有返回值,如果在类中将之声明为常成员函数,正确的是( )。
单选题有如下程序:#include<iostream>using namespace std;class XX{protected:int k;public:XX(int n=5):k(n){}~xx(){cout<<"XX";}virtual void f() const=0;};inline void XX:: f()const{cout<<k+3;};class YY: public XX{public:~YY(){cout<<"YY";}void f() const{cout<<k-3;XX::f();}};int main(){XX p. f();delete return 0;}执行上面的程序将输出( )。
单选题下列关于类成员对象构造函数调用顺序的叙述中,正确的是______。
单选题在C++中既可以用于文件输入又可以用于文件输出的流类是______。
单选题有如下程序:#include<iostream>using namespace std;int main(){int i=1,s=0;while(s<30){s+=i*i:i++;}cout<<s<<endl:return0;}运行后的输出结果是( )。
单选题下列运算符不能重载为友元函数的是{{U}} {{/U}}。
A. = () [] →
B. + - ++ --
C. > < >= <=
D. += -= *= /=
单选题要利用C++流进行文件操作,必须在程序中包含的头文件是( )。
单选题设有关键码序列(66,13,51,76,81,26,57,69,23),要按关键码值递增的次序排序,若采用速排序法,并以第一个元素为划分的基准,那么第一趟划分后的结果为( )。
单选题类的析构函数的作用是 A) 一般成员函数的初始化 B) 类的初始化 C) 对象的初始化 D) 删除类创建的对象
单选题要定义一个引用变量p,使之引用类MyClass的一个对象,正确的定义语句是______。
单选题已知outfle是一个输出流对象,要想将outfile的文件指针定位到当前位置之前321字节处,正确的函数调用语句是( )。 A.outfle.seekp(321,ios_base::cur); B.outfile.seekp(321,ios_base::beg); C.outfile.seekp(-321,ios_base::beg); D.outfile.seekp(-321,ios_base::cur);
单选题将下面类TestClass中的函数fun()的对象成员n值修改为100的语句应该是
____
。
class TcstClass
{
public:
TestClass(int x){n=x;}
void SetNum(int n1){n=n1;}
private:
int n;
}
int fun()
{
TestClass
*
ptr=new TestClass(45);
______;
}
单选题有以下程序 #include"iostream.h" void main( ) int i=1,j=1,k=2; if((j++||k++)&&i++) cout<<i<<","<<j<<","<<k; cout<<endl; 执行后输出结果是
单选题在一棵二叉树上第5层的结点数最多是
____
。
单选题下列程序段中包含4个函数,其中具有隐含this指针的是( )。 int fun1(); class Test public: int fun2(); friend int fun3(); static int fun4(); ;
单选题已知类IMS中两个成员函数的声明为“void listen()const;”与“void speak();”,另有两个对象的定义为“IMS obj1;”与“const IMS obj2;”,则下列语句中,产生编译错误的是( )。
单选题有如下程序:#include<iostream>using namespace std;double add(double a,double b,double c=1){return a+b+c:}int main()int result=add(2,3);cout<<result<<endl:return0;}运行后的输出结果是( )。
单选题有如下程序: #inc1ude<iostream> using namespace std; c1ass Comp1ex { double re,im; public: Comp1ex(double r,double i):re(r), im(i){} double real()const{return re,} double image()const{return im;} Comp1ex im+=a.im; return *this; } }; ostream cout<<(x+=y)<<end1; retum 0; } 执行这个程序的输出结果是( )。
单选题有关析构函数的说法中错误的是
单选题有以下结构体说明和变量的定义,且指针p指向变量a,指针q指向变量b。则不能把结点b连接到结点a之后的语句是( )。 struct node chardata; struct node if next; a,b,*p:&a,*q=&b;
