void setValue(int x,int y) { xx = x;yy = y;} int max( ){
return xx > yy? xx:yy; } };
void main( ){ CMax m( );
m.setValue(20,30); cout <<″Max=″<} 45.#include
using namespace std; class A{ public:
char name[255]; private:
char * getName( ) { return name; } };
class B:public A{ public: B(char * n){
strcpy ( name,n); } };
void main( ){
B b(″Hello!″); cout <<″Name:″<}
四、完成程序题(本大题共5小题,每小题4分,共20分) 46.将下面程序补充完整,使程序输出结果为: Begin Welcome Show End
程序如下: #include
using namespace std; class A{ public: __________{
cout <<″Begin″<} void show( ){ cout<<″Show″<}
___________{ cout<<″End″<} };
A object; int main( ){
cout <<″Welcome″ 47.请将下面程序补充完整,使程序可以正常打印9×9乘法口诀。  #include   using namespace std;  class A { private:  int a;int b;  public: __________  { a = x;b = y; } void set(int x,int y) { a = x;b = y; } void display( ){ cout<} };   int main( ){ A a(1,1);   for(int i=1;i<=9;i++){ for(int j=1;____;j++){ a.set(j,i);  a.display( );  cout<<″″;  }  cout<}  return 0;  }  48.将下面程序补充完整,使程序可以输入学生信息并计算平均成绩。  #include  #include   using namespace std;  class Student{ private:   char name[255];  int score[10];  public:   Student(char n[ ],int s[ ]){ ___________;  for(int i=0;i<10;i++){ score[i]=s[i];  } }  void Show( ){ int sum=0;   for(int i=0;i<10;i++){ _______________; }  cout<<″名字:″< < name<<″,平均成绩:″<} };   void main( ){ char name[255];  int score[10];   cout<<″姓名:″;cin>>name;  for(int i=0;i<10;i++){  cout<<″成绩″ Student s(name,score);  s.Show( );  }  49.将下面程序补充完整,使程序可以正常运行,并释放内存。  #include  _______ class A { private:  T * data;  int length;  public:  A (int len){ length=len;   data=new T[len];  }  ~A( ){ _________ }  T& operator[](int i){ return data[i];  } };   int main( ){ A obj(2);  obj[0]=1;  obj[1]=2;   cout 50.将下面程序补充完整,使程序运行结果为:  C1ass A Class B 程序如下:  #include  #include  class A{ public:   virtual void GetA( ) = 0;  };   class B:public A{ private:   char str[32];  public:  void GetA( ){  cout<<″Class A″<}  const char * GetB( ) {_____ }  B(char * s){  strcpy(str,s);  } };   void main( ){ A * a;   B b(″Class B″);  a=_________;  a-> GetA( );  cout 五、程序分析题(本大题共2小题,每小题5分,共10分) 51. #include   using namespace std;  int main( ){ int i,j;   for(i=l;i<=4;i+=1) for(j=2;j<=4;j+=j){ if(i+j<5)  cout<<″ + ″;  else  cout<<″ * ″;  }  return 0;