全国2006年10月高等教育自学考试
void other(void);
cout<<"i a b c\n";
cout<<setw(5)<<i<<setw(5)<<a<<setw(5)<<b<<setw(5)<<c<<endl;
c=c+8; other();
cout<<setw(5)<<i<<setw(5)<<a<<setw(5)<<b<<setw(5)<<c<<endl;
i=i+10; other();
}
32.写出下面程序的输出结果。
#include <iostream.h>
class A
{
private:
int X,Y;
public:
A() {
X=Y=0;
cout<<"Default Constructor called."<<endl;
}
A(int xx,int yy) {
X=xx;Y=yy;
cout<< "Constructor called."<<endl;
}
~A() {
cout<<"Destructor called."<<endl;
}
};
void main()
{
A *p1=new A;
delete p1;
p1=new A(1,2);
delete p1;
}
33.写出下面程序的输出结果。
#include <iostream.h>
class A {
private: int a;
public:
void set( int x) { a = x; }
void show() { cout<<"a="<<a<<","; }
};
class B: public A {
private: int b;
public:
void set(int x=0) { A::set(x);b=x; }
void set(int x, int y) { A::set(x); b=y; }
void show() { A::show(); cout<<"b="<<b<<endl; }
};
════════════════════════════════════════════════════════════════════
- 本套试题共分8页,当前页是第7页-