单选题有如下程序段 #include void
main( ) { int a=14,b=15,x; char
c='A'; x=(a&&b) &&(c<'B') ;
cout < < x;} 执行该程序段后,x的值为
A. ture
B. false
C. 0
D. 1
单选题有如下程序: #include<iostream> using namespace std; class VAC public: int f() constreturn 3; int f() return 5; ; int main() VAC v1; const VAC v2; cout<<v1.f()<<v2.f(); return 0; 运行时的输出结果是( )。
单选题有如下类定义 c1ass MyClass public: ________ Private: int data; }; 若要为MyClass类重载流输入运算符>>,使得程序中可以“cin>>obj;”形式输入MyClass类的对象obj,则横线处的声明语句应为( )。
单选题关于函数重载,下列叙述中错误的是( )。 A) 重载函数的函数名必须相同 B) 重载函数必须在参数个数或类型上有所不同 C) 重载函数的返回值类型必须相同 D) 重载函数的函数体可以有所不同
单选题执行语句:cout<<setfill('*')<<setw(10)<<seffill('#')<<left<<123<<"0K"<<end1;return 0;后将输出( )。
单选题下列选项中,合法的用户标识符是______。 A) char B) _2Test C) D/max D) A) dat
单选题有如下类声明:
class Base{
protected;
int amount;
public;
Base(int n=0):amount(n){}
int getAmount()const{return amount;}
};
class Derived:public Base{
protected;
int value;
public;
Derived(int m,int n):value(m).Base(n){}
Int getData()const{return value+amount;}
};
己知x是一个Derived对象,则下列表达式中正确的是______。
单选题下面程序的运行结果是( )。
#include void main()
{
int num=1:
int&ref=num; ref=ref+2:
cout<
单选题下面程序的运行结果是( )。 #include<iostream.h> int x=5; int fun(int a) { int c; c=x*a; return c; } void main() { int x=3,a=4; x=x+fun(a); cout<<"x="<<x<<endl; }
单选题有如下程序: #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. 42,42
B. 23,23
C. 23,42
D. 42,23
单选题下列变量名中,合法的( )。
单选题下列程序的运行结果是( )。
#include <iostream.h>
class Location {
private:
int X,Y;
public:
void init(int=0,in=0);
Void valueX(int val) { X=val;}
int valueX( ) { return X;}
void valueY(int val) { Y=val;}
int valueY( ) { return Y;} };
void Location::init(int initX,int initY)
{ X=initX;
Y=initY;}
void main( )
{ Location A,B;
A.init( );
A.valueX(5);
cout < < A.valueX( ) < < end1 < < A.valueY( ) < < end1;
B.init(6,2);
B.valeY(4);
cout < < B.valueX( ) < < end1 < < B.valueY( ) < < end1;}
单选题下列程序的输出结果为( )。
# include <iostream.h>
int func(int n)
{
if (n<1)return 1;
else return n + func (n-1);
return 0;
{
void main( )
{
cout << func (5) << endl;
}
单选题有以下程序 #include<iostream.h> void
ss(char*s,char t) { while(*s) {
if(*S==t)*s=t-'a'+'A'; s++;} } void main(
) { char strl[100]="abcddfefdbd",c='d':
ss(strl,c) ;cout<<strl;} 程序运行后的输出结果是
A. ABCDDEfEBD
B. abcDDfefDbD
C. abcAAfefALbA
D. Abcddfefdbd
单选题若目前D盘根目录下并不存在test.txt文件,则下列打开文件方式不会自动创建test.txt文件的是______c A.ifstream fin;fin.open("d:/test.txt",ios_base::in); B.fstream fio;fio.open("d:/test.txt",ios_base::out); C.ofstream fout;fout.open("d:/test.txt",ios_base::out); D.ofstream fout;fout.open("d./test.txt",ios_base::app);
单选题下列程序的运行结果是 #include <iostream.h> class Location
{ private: int X,Y; public: void
init(int=0,in=0); Void valueX(int val) { X=val;} int valueX(
) { return X;} void valueY(int val) { Y=val;} int
valueY( ) { return Y;} }; void Location::init(int initX,int
initY) { X=initX; Y=initY;} void main(
) { Location A,B; A.init( );
A.valueX(5); cout < < A.valueX( ) < < end1 < < A.valueY( ) < <
end1; B.init(6,2); B.valeY(4); cout < <
B.valueX( ) < < end1 < < B.valueY( ) < < end1;}
A. 5 0 6 4
B. 0 0 6 4
C. 5 0 6 2
D. 0 0 6 2
单选题下列不属于C++预定义的流对象的是
单选题有如下程序:
#include <iostream>
using namespace std;
class A
public:
~A() {cout<<"~A";}
};
class B:public A
public:
~B() {cout<<"-B";delete p;}
int main( )
B obj;
return 0;
单选题有如下类定义: class Sample{ public; Sample(int x):ref(x){} //① private:Sample():ref(0){} //② static int val=5; //③ const int ref; //④};上述程序段中,错误的语句是( )。
单选题当需要将一个函数boolisnunlber(charc)声明为内联函数时,此内联函数的函数原型为( )。
