42. #include < iostream, h >
class test {
private : int x, y;
public : void testl ( int a, int b) { x = a ; y = b;}
int max( );
};
int test:max( ) {if(x>y) return x;else return y;}
void main( ){
test a;
a. testl ( 1,3);
cout << a. max ( ) << endl;
}
43. #include < iostream, h >
void main() {
int x =5;
const int * const p = &x;
* p =88;
cout << * p << endl;
}
44. #include < iostream, h >
class point
{
private : float x, y ;
public : f( float a, float b) { x = a ; y = b ; }
f( ) {x=O;y=O;}
void getx( ) { cout < < x < < endl; }
void gety ( ) { cout < < y < < endl ; }
}
class pointl
}
private : float x, y ;
public : f( float a, float b) { x = a; y = b ; }
f( ){x=l;y=l;}
void getx( ) {cout < void gety( ) {cout < }; main( ) I point a; a.f(); a. getx( ) ;a. gety ( ); } 45. #include < iostream, h > void main( ) { string strl (" we are here" ); cout << strl << endl; } 四、完成程序題(本大題共5小題,每題4分,共20分) 46.在下面程序的下劃線處填上正確的數(shù)據(jù)類型,保證程序具有如下輸出結(jié)果: 0 17 17,17,17 源程序如下: #include < iostream > using namespace std; class base { public : ______________num; base ( ) { } }; int base::hum = 0; void main( ) { cout << base::num << endl; _________________* p=&base : :num; *p=17; cout << base::num << end1; base a,b; cout << * p<<"," << a. hum << "," < 47.在下面橫線處填上正確的內(nèi)容,完成類的定義。 class Base { int x; static const int b; public: Base( int, int); const int &a; }; ______________b =15; Base::Base(int i,int j): ___________{ } 48.完成下面程序中的show函數(shù)的定義,使其運行結(jié)果如下: In base In derived 程序清單如下: #include using namespace std; class base { pubhc : virtual void print( ) { cout << "In base" << endl; } }; class derived: public base { public : void print( ) { cout << "In derived" << endl; } }; void show(base * pb,void (base:: * pf) ( ) ) { _________ } void main( ) { base b; derived d ; show ( &b, base::print); show ( &d, base::print); }
2010年10月自考試題及答案發(fā)布專題
各地2010年10月自考成績查詢時間及查詢方式匯總
考試吧策劃:2011年自學(xué)考試報考完全指南