单选题有如下类定义:
class B{
public:
void fun1(){}
private:
void fun2(){}
protected:
void fun3(){}
};
class D:public B{
protected:
void fun4(){}
};
若obj是类D的对象,则下列语句中不违反访问控制权限的是______。
单选题C++中的模板包括______。
单选题由于常对象不能被更新,因此______。
单选题以下程序企图把从键盘终端输入的字符输出到名为abc.txt的文件中,当从终端读到字符"#"时,结束输入和输出操作。但该程序有错。
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
ofstream ofile; char ch;
ofile.open("d://abc.txt", "W");
do{
cin>>ch;
ofile.put(ch);
}while(ch!="#");
ofile.close();
return 0;
}
程序出错的原因是( )。
单选题下列关于this指针的叙述中,正确的是
____
。
单选题有如下的程序:
#include
#include
usingnamespacestd;
classMyString
{public:
MyString(constchar*s);
MyString(){delete[]data;}
protected:
unsignedlem
char*data;};
MyStrin9::MyString(constchar*s)
{len=strlen(s);
data=newchar[len+1];
strcpy(data,s);}
intmain()
{MyStringa("C++Programing");
MyStringb(a);
return0;}
在运行上面的程序时出错,出错的原因是( )。
单选题有如下函数模板: template<typename T,typenaine U> T cast(U u)return u; 其功能是将U类型数据转换为T类型数据。已知i为int型变量,下列对模板函数cast的调用中正确的是 A) cast(i); B) cast<>(i); C) cast<char*,int>(i); D) cast<double,int>(i);
单选题下列关于构造函数和析构函数的描述,错误的是( )。
单选题设char型变量x中的值为10100111,则表达式(2+x)^(~3)的值是
单选题下列有关类继承的叙述中,错误的是( )。
单选题有如下类定义: class B { public:void fun1(){} private:void fun2(){} protected:void fun3(){} }; class D:public B { protected:void fun4(){} }; 若obj是类D的对象,则下列语句中不违反访问控制权限的是( )。
单选题为了取代C中带参数的宏,在C++中使用( )。
单选题下述静态数据成员的特征中,错误的是( )。
单选题以下程序的输出结果是( )。 #include <iostream.h> Void main() int a[3][3]=1,2),3,4,5,6i,j,s=0; for(i=1;i<3;i++) for(j=0;j<i;j++) s+=a[i][j]; cout<<s<<endl; A) 14 B) 19 C) 20 D) 21
单选题有如下类定义:
class Point {
private:
static int how_many;
};
______how_many=0;
要初始化Point类的静态成员how_many,下画线处应填入的内容是______。
单选题有以下程序: #include <iostream> using namespace std; int main() { int x=15; while(x>10 if(x/3) { x++; break; } } cout<<x<<end1; return 0; } 执行后的输出结果是
单选题C++语言中类的定义的结束声明的符号是A) B) ,C) ;D)
单选题NULL是指 A) 0 B) 空格 C) 未知的值或无任何值 D) 空字符串
单选题下面程序的输出结果是( )。 #include<iostream.h> Class example int a; public: example(int B.a=b++; void print()a=a+1 cout<<a<<““; void print()constcout<<a<<““; ; void main() example x(3); Const example y(2); x.print(); y.print();
单选题有如下函数模板: template <typename T,typename U> T cast(U u)return u; 其功能是将U类型数据转换为T类型数据。已知i为int型变量,下列对模板函数cast的调用中正确的是( )。 A.cast(i); B.cast<>(i); C.cast<char*,int>(i); D.cast<double,int>(i);
