单选题有如下程序:
#include<iostream>
using namespace std;
class A{
public:
A(int i):rl(i){}
void print(){cout<<"E"<<r1<<"-";}
void print()const{cout<<"C"<<r1*r1<<"-";}
private:
int rl;
};
int main(){
A al(2); const A a2(4);
a1.print(); a2.print();
return 0;
}
运行时的输出结果是______。
单选题有如下类定义:class AA{int a;public:int getRef()const{return &a;}//①int getValue()const{return a;}//②void set(int n)const{a=n;}//③friend void show(AA aa)const{cout<<a;}//④};其中四个函数的定义中正确的是( )。
单选题函数swap(a,n)可完成对a数组从第1个元素到第n个元素两两交换。其中b[0]=1;b[1]=2;swap(b,2)。在运行调用函数中的语句后,b[0]和b[1]的值分别为( )。
单选题数据字典(DD)所定义的对象都包含于( )。
单选题有如下类声明:
class MyBASE {
int k;
public:
void set(int n) {k=n;}
int get()const {return k; }
};
class MyDERIVED: protected MyBASE {
Protected:
int j;
public:
void set(int m,int n){MyBASE:: set(m);j=n;}
int get () const {return MyBASE:: get ()+j; }
};
则类MyDERIVED 中保护的数据成员和成员函数的个数是______ 。
单选题面向对象程序设计将数据和什么放在一起,作为一个相互依存、不可分割的整体来处理?
A. 对数据的操作
B. 信息
C. 数据隐藏
D. 数据抽象
单选题已知数据表A中每个元素距其最终位置不远,为节省时间,应采用的算法是
____
。
单选题在软件开发中,需求分析阶段产生的主要文档是
____
。
单选题执行语句序列 ofstream outfite("data.dat"); if(...)cout<<"ok";else cout<<"fail"; 后,如果文件打开成功,显示“ok”,否则显示“fail”。由此可知,上面if语句的“…”处的表达式是
单选题下列类的定义中,有( )处语法错误。 class Base public: Base() Base(int i) data=i; private: int data; ; class Derive: public Base public: Derive():Base(0) Derive(int x) d=x; void setvalue(int i) data=i; private: d; ; A.1 B.2 C.3 D.4
单选题有如下程序:
#include<iostream>
using namespace std;
class Book{
public:
Book(char*t=" "){strcpy(title,t);}
______
pnvate:
char title[40];
};
class Novel:public Book{
public:
Novel(char*t=" "):Book(t){}
char*Category()const{retum"文学";}
};
int main(){
Book*pb;
pb=new Novel();
cout<<pb->Category();
delete pb;
retum 0;
}
若程序运行时输出结果是"文学",则横线处缺失的语句是______。
单选题若AA为一个类,a为该类的私有整型数据成员,getA()为该类的一个非静态公有成员函数,功能是返回a的值。如果x为该类的一个对象,要在类外访问x对象中a的值,正确的访问格式为( )。
单选题有如下程序: #include<iostream> using namespace std; class Base protected: Base()cout<<'Base'; Base(char c)cout<<c; ; class Derived:public Base public: Derived(char c)cout<<c; ; int main() Derived d('Derived'); return 0; 执行这个程序屏幕上将显示输出( )。 A) Derived B) DerivedBase C) BaseDerived D) DerivedDerived
单选题下面程序的运行结果为 #include<iostream.h> class A int num; public: A(int)num=i; A(ABm)num=a.num++; void print()cout<<num; ; void main() Aa(1),b(
单选题执行以下程序后,test.txt文件的内容是(若文件能正常打开)______。
#include
main()
{ FILE *fp;
char *s1="Fortran",*s2="Basic";
if((fp=fopen("test.txt","wb"))==NULL)
{ printf("Can''t open test.txt file\n"); exit(1);}
fwrite(s1,7,1,fp); /*把从地址s1开始的7个字符写到fp所指文件中*/
f seek(fp, 0L,SEEK_SET); /*文件位置指针移到文件开头*/
fwrite(s2,5,1,fp);
fclose(fp);
}
单选题有下列程序: #include<stdio.h> void fun(int *a,int *b) int *c; c=a;a=b;b=c; void main() int x=3,y=5,*p=&x,*q=&y; fun(p,q);printf("%d,%d,",*p,*q); fun(&x,&y);printf("%d,%d/n",*p,*q) 程序运行后的输出结果是( )。
单选题有如下程序: #include<iostream.h> using
namespace std; class Base {
public: Base(){cout<<"BB"; f(); }
void f(){cout<<"BF";} }; class
Derived:public Base { public:
Derived(){cout<<"DD";} void f(){cout<<"Df";}
}; int main(){Derived d;return 0;}
执行上面的程序将输出______。
A.BBBfDD
B.BBDfDDDf
C.DD
D.DDBBBf
单选题在函数中,可以用auto、extern、register和static这四个关键字中的一个来说明变量的存储类型,如果不说明存储类型,则默认的存储类型是______。
单选题若有int x[]={1,2,3,4,5,6,7,8,9,10},*p=x;则值为4的表达式是 ______。
单选题下列字符常量表示中,______ 是错误的。