2012面向对象程序设计试题集(6)

2019-04-02 13:27

public:

Csample( );

void Display( ); }; int Csample::k=0;

Csample::Csample( ) { i=0; k++; }

void Csample::Display( ) { cout<<\void main( )

{ Csample a,b; a.Display( ); b.Display( ); }

以下程序的输出结果是 #include class A

{ public: A(char *s) { cout<

{ public: B(char *s1, char *s2):A(s1)

{ cout<

C(char*s1,char *s2):A(s1)

{ cout<

public:

D(char *s1, char *s2,char *s3, char *s4):B(s1,s2),C(s1,s3),A(s1) { cout<

{ D *p=new D(\ delete p; }

下面程序的运行结果为: #include void main() { int i,k=0;

for(i=0; ;i++) {k++;

if(k%3= =0) break; } cout<

下面程序的运行结果为: #include class Point{ int x,y; public:

Point(int x1=0,int y1=8){x=x1;y=y1;} ~Point(){cout<<\void main() {Point a;

}; Point b(10,10); }

下面程序的运行结果为: #include using namespace std; class Sp { int x; public:

void setx(int i) {x=i;}

int putx() {return x;} }; void main()

{ Sp a[3],*p;

for (int i=0;i<=2;i++) a[i].setx(i); p=a; for (;i>0;i--)

cout<putx()<<\ cout<

下面程序的运行结果为: #include using namespace std; class MyClass{ public:

MyClass(){cout<

MyClass p1,*p2; p2=new MyClass(?X?); delete p2; return 0; }

下面程序的运行结果为: #include #include using namespace std; class XCD{ char *a; int b; public:

XCD(char *aa, int bb) {

a=new char[strlen(aa)+1]; strcpy(a,aa); b=bb; }

char* Geta() {return a;} int Getb() { return b;} };

int main(){

char *p1=”abcd”, *p2=”weirong”; int d1=6,d2=8;

XCD x(p1,d1), y(p2,d2);

cout<

以下程序的输出结果为 。 char ch1='b',ch2; ch2=ch1+'A'-'a';

cout<

以下程序的输出结果为 。 #include \void main()

{int n[2]={0},i,j; for(i=0;i<2;i++)

for(j=0;j<2;j++) n[j]=n[i]+1; for(i=0;i<2;i++) cout<

以下程序的输出结果为 。 #include void main() { int i,k=0; for(i=0; ;i++) {k++;

if(k%3= =0) break; }

cout<

下面程序的运行结果是________。 #include \ class test {

private: int num; float fl; public: test( );

int getint( ){return num;} float getfloat( ){return fl;} ~test( ); };

test::test( ) {

cout << \ num=0;fl=0.0;

}

test::~test( ) {

cout << \}

void main( ) {

test array[2];

cout << array[1].getint( )<< \ }

下面程序的运行结果是________。 #include using namespace std; class A{ int a; public: A():a(9){}

virtual void print() const {cout<

class B:public A{ char b; public:

B(){b= ?S?;}

void print()const{cout<

void show(A& X){X.print();} int main() { A d1,*p; B d2; p=&d2;

d1.print(); d2.print(); p->print();

show(d1); show(d2); return 0; }

下列程序运行结果为:

#include

void main() { int i,j,m=0,n=0; for(i=0;i<2;i++) for(j=0;j<2;j++) if(j>=i) m=1;n++; cout<

}

写出下列程序运行结果:

#include

void main()

{ int a,b; for(a=1,b=1;a<=100;a++) { if(b>=10)break; if(b%3= =1) { b+=3;continue;} } cout<

}

下面程序段的运行结果为:

for(y=1;y<10;) y=((x=3*y,x+1),x-1); cout<<“x=”<

A.x=27,y=27 B.x=12,y=13 C.x=15,y=14 D.x=y=27 下面程序段的运行结果是为:

i=1;a=0;s=1; do {a=a+s*i;s=-s;i++; } while(I<=10); cout<<“a=”<

下面程序段的运行结果为: #include void main() {int i,t,sum=0;

for(t=i=1;i<=10; ) {sum+=t;++i; if(i%3= =0) t=-i; else t=i;}

cout<<“sum=”<

下面程序的输出结果为: #include”iostream.h” f(int a) {int b=0;

static int c=3; b++;c++;

return(a+b+c); }

void main( ) {int a=2,I;

for(I=0;I<3;I++) cout<

下面程序的输出结果为: #include class Point{ int x,y; public:

Point(){x=1;y=1;}

~Point(){cout<<\


2012面向对象程序设计试题集(6).doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:导案22《狼牙山五壮士》

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: