填空题

试题源程序文件清单如下:
//main.cpp
#include<iostrcam.h>
class vehicle
private:
int MaxSpeed;
int Weight;
public:
//**********found**********
vehicle(int maxspecd,int weight): (1)
~vehiclc();
int getMaxSpeed()return MaxSpeed;
int getWeight()return Weight;
:
//**********found**********
class hicycle: (2) public vehicle
pnvate:
int Height;
public:
bicycle(int maxspeed ,int weight,int height):vehicle( maxspeed ,weight), Height( height)
int getHeight()return Height;;
;
//**********found**********
class motorcar: (3) public vehicle
private:
int SeatNum:
public:
motorcar( int maxspeed,int weight,int sealnum):vehicle( maxspeed, weight), SeatNum( seatnum)
int getSeatNum()return SeatNum;;
;
//**********found**********
class motorcycle: (4)
public:
motorcycle( int maxspeed ,int weight,int height):
vehicle( maxspeed ,weight), bicycle( maxspeed, weight, height), motorcar( maxspeed, weight,1)
;
void main()
motorcycle a(80,150,100);
cout<<a. getMaxSpeed()<<endl;
cout<<a. getWeight()<<endl;
cout<<a. getHeight()<<endl;
cout<<a. getSeatNum()<<endl;
【参考答案】
virtual
热门
试题
问答题
试题源程序文件清单如下: M atrix.h #include<iostream> #include<iomanip> using namespace std; const int M=18: const int N=18: class Matrix int array[M][N]; public: Matrix() int getElement( int. i,int j) constreturn array[i][j]; voicl setElement(int i,int j ,int value)array[i][j]=value; int max_value() const; void show( const char * s) const cout<<endl<<s; for (int i=0;i<M;i++) cout<<endl; for ( int j=0;j<N;j++) cout<<setw (4)<<array [i] [j] ; ; void readFromFile( const char * ,Matrix &) ; void writeToFile( char * ,const Matrix &) ; main. cpp #include Matrix. h #include<fstream> void readFromFile( const char * f,Matrix & m) ifstream infile ( f) ; if( infile. fail()) cerr<< 打开输入文件失败! ;return; int k; for( int, i=0 ;i<M ;i++) for(int j=0;j<N;j++) infile>>k ; m. setElement(i,j,k) ; int Matrix::max_value( ) const ********33******** int main( ) Matrix m ; readFromFile ( K : K01 61010001 in. dat ,m ) ; m. show( Matrix: ) ; cout<<endl << 最大元素 : <<m. max_value( )<<endl; writeToFile ( K: K01 61010001 ,m) ; return 0 ;