我一直没找出来这程序的错误,求指点!
#include<iostream>using namespace std;
class plane
{
private:
double aerofoil;
double airframe;
double empennage;
double voyage;
int passenger;
public:
plane(double,double,double,double,int);
virtual void display();
};
void plane::display()
{
cout<<"\t"<<aerofoil<<"\t"<<airframe<<"\t"<<empennage<"\t"<voyage<<"\t"<<passenger;
}
plane::plane(double wing,double frame,double tail,double distance,int num)
{
aerofoil=wing;
airframe=frame;
empennage=tail;
voyage=distance;
passenger=num;
}
class fighter:public plane
{
private:
int missile;
public:
fighter(double,double,double,double,int,int);
void fight;
void display();
};
fighter::fighter(double wing,double frame,double tail,double distance,
int num,int load_missile):plane(wing,frame,tail,distance,num)
{
missile=load_missile;
}
void fighter::fight()
{
cout<<"Fight!"<<endl;
}
void fighter::display()
{
cout<<"This is a fighter!"<<endl;
plane::display();
cout<<"\t"<<missile<<endl;
}
class bomber:public plane
{
private:
double bomb;
public:
bomber(double,double,double,double,int,double);
void atack();
double getbomb();
void display();
};
bomber::bomber(double wing,double frame,double tail,double distance,int num,double load_bomb):plane(wing,frame,tail,distance,num)
{
bomb=load_bomb;
}
void bomber::atack()
{
cout<<"Atack!"<<endl;
}
double bomber::getbomb()
{
return bomb;
}
void bomber::display()
{
cout<<"This is a bomber!"<<endl;
plane::display();
cout<<"\t"<<bomb<<endl;
}
class fighter_bomber:virtual public fighter,virtual public bomber
{
public:
fighter_bomber(double,double,double,double,int,intdouble);
void display();
};
void fighter_bomber::display()
{
cout<<"This is a fighter_bomber!"<<endl;
fighter::display();
cout<<"\t"<<getbomb<<endl;
fight();
atack();
}
fighter_bomber::fighter_bomber(double wing,double frame,double tail,double distance,int num,int load_missile,double load_bomb):fighter
(wing,frame,tail,distance,num,load_missile),bomber(wing,frame,tail,distance,num,load_bomb)
{}
void main()
{
fighter f(10.0,6.0,2.5,1800,1,8);
f.display();
bomber b(30,9,6,12000,12,6000);
b.display();
fighter_bomber fb(20,7,3.2,4000,2,6,2500);
fb.display();
}