注册 登录
编程论坛 VC++/MFC

我一直没找出来这程序的错误,求指点!

maxwell1st 发布于 2014-12-19 12:54, 515 次点击
#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();
}
2 回复
#2
wp2319572014-12-19 13:16
怎么发这种奇葩的代码  摆明了不想让别人帮你调试
#3
hao3412022014-12-23 21:06
(17)cout语法错误,自己看。
类,public:void fight()
void fighter_bomber::display()函数中cout中getbomb()
都是语法错误,你很不仔细啊。
1