{
cout< A::operator++() { cout<<++x<<' '<<++y<<'\\n'; } void main() { A a(1,2); ++a; a++; } 答案:空 1:2 3 2 3 37、以下程序输出结果的第一行是________,第二行是________。 # include public: virtual void f(){ cout <<\ }; class Y: public X { public: void f(){cout<<\ }; void main(void) { Y y,*xy=&y;X *xp=&y; xy ->f(); xp->f(); } 答案:bb bb 38、阅读以下程序。 #include void convert(char a) { c2=(c1=a)-32; } void disp() { cout< void main() { Char a,b; a.convert('m'); a.disp(); b.convert('n'); b.disp(); } 执行结果第一行为________________,第二行为________________。 答案:m转换为M n转换为N 39、多态性分为两种:_____________(编译时多态)和_____________(运行时多态)。 答案:静态多态 动态多态 40、程序输出的第一行是________,第二行是________。 # include Ba(int b){x=b;y=x+x;} int Gety(void){return y;} }; class A: public Ba { public: A(int c):Ba(c){} int Getx(void){return x;} }; class B:public Ba { public: B(int d):Ba(d){} int Getx(){return x;} }; class C:public B, public A { public: C(int e):A(e+30),B(e+100){ } }; void main(void) { C c(100); cout < 答案:260 400 130 200 41、以下程序输出的第一行是_______,第二行是________。 # include Shape( ){} virtual float Area( )=0; }; class Circle:public Shape { float r; public; Circle(float c){r=c;} float Area(){return 3*r*r;} }; class Rectangle:public Shape { float h,w; public: Rectangle(float c,float d){h=c;w=d;} float Area(){return h * w;} }; void fun(Shape * s) {cout< Circle c(4); fun(&c); Rectangle r(5,2); fun(&r); } 答案:48 10 42、以下程序输出结果的第一行是__________,第二行是__________。 # include public: void f(){ cout <<\}; class Y: public X { public: void f(){cout<<\}; void main(void) { Y y , *xy=&y ; X *xp=&y ; xy ->f() ; xp->f() ; } 答案:bb aa 43、私有派生中,基类中的public成员在派生类中是________成员,protected成员在派生类中是________成员。 答案:private :private 44、以下程序输出的第二行是________,第四行是________。 # include static int count; A(int a =0) { i=a+count; count++; cout< int A::count=0; void main(void) { A a(100); A b; A c(200); cout<<\} 答案:2 1 count=3 45、保护派生中,基类中的public成员在派生类中是________成员,protected成员在派生类中是________成员。 答案:protected 【或】 保护 protected 【或】 保护 46、以下程序输出的第一行是________,第二行是________,第三行是________。 # include T a,b;a.x=10;b.x=20; cout<<\ } 答案:a.x=20 【或】 20 b.x=20 【或】 20 T::x=20 【或】 20 46、继承权限有三种:________派生、________派生、________派生。 答案:公有 私有 保护 47、以下程序输出的第一行是________,第二行是________,第三行是________,第四行是________。 #include char str[20]; public: Base(char *s=\ { strcpy(str,s); cout< class h1:public virtual Base { char str1[20]; public: h1(char *s1,char *s2):Base(s1) { strcpy(str1,s2); cout< class h2:virtual public Base { char str2[20]; public: h2(char *s1,char *s2):Base(s1) { strcpy(str2,s2); cout< class h3:public h1,public h2 { char str3[20]; public: h3(char *s1,char *s2,char *s3,char *s4):h1(s1,s2),h2(s1,s3) { strcpy(str3,s4); cout< void main() { h3 a(\} 答案:default h1 h2 h3 48、通过重载运算符\,直接实现两个一维数组对应元素相加的运算。设数组a、b分别为int a[10]={1,2,3,4,5,6,7,8,9,10},int b[10]={4,5,6,7,8,9,10,11,12,13},则两数组相加后,结果为{5,7,9,11,13,15,17,19,21,23}。类似地,重载运算符\,实现复合赋值运算。 # include