三、改错题(本大题共5小题,每小题4分,共20分)
下面的每题中有一处错误,请在“答题纸”上将错误所在行写出并给出修改意见。
41. #include <iostream.h>
class point{
private: float x,y;
public: point( float a,float b){x=a;y=b;}
void f(){x=0;y =0;}
void getx(){cout<<x<<endl;}
void gety(){cout<<y<<endl;}
} ;
main( ) {
point a(3.5);
a.getx( );
}
42. #include < iostream. h >
main( ) {
int x =7;
const int *p = &x;
*p =99;
cout << *p << endl;
}
43. #include < iostream. h >
class test{
private: int x;y;
public: voicl f( int a,int b) { x = a;y = b; }
int max( ) { return(x > y) ? x:y; }
};
main( ) {
test a;
a. f( 1 ,3) ;
cout << a. max( ) << endl;
}
44. #include <iostream h >
class test{
private: int x;
public:test(int a) { x = a; }
void set(int a) { x = a;}
void get( ) { cout << x << endl; }
};
class testl: public test{
private: int x;
public :testl ( int a) { x = a; }
void set( int a) { x = a;}
void get( ) { cout <<′′<< endl; }
};
45. #include < iostream. h >
class f{
private: int x,y;
public: fl ( int a,int b) { x = a;y = b; }
void print( ) { cout << x << --<< y << endl; }
};
main( ) {
f a;
float x = 1.0,y = 2. 0;
a. fl ( x,y) ;
a. print( ) ;
}