我试图解决这个错误,但我没有做什么..得到错误的呼叫没有匹配功能,飞艇飞艇
#include<iostream>
#include<string>
using namespace std;
class AirShip{
private:
int passenger;
double cargo;
public:
AirShip(int x,double y)
{
passenger=x;
cargo=y;
}
void show()
{
cout<<"passenger="<<passenger<<endl;
cout<<"cargo="<<passenger<<endl;
}
};
class AirPlane: protected AirShip{
private:
string engine;
double range;
public:
AirPlane(string a,double b)
{
engine=a;
range=b;
}
void show()
{
cout<<"engine="<<engine<<endl;
cout<<"range="<<range<<endl;
}
};
的错误是: 错误:呼叫没有匹配功能到'AirShip :: AirShip()' 需要帮助... 我稍后会把主要功能,因为错误在这里。
相关:http://stackoverflow.com/questions/4981241/no-default-constructor-exists-for-class –
您是否曾尝试为'AirShip'添加一个空的构造函数,因为根据错误似乎是什么失踪。 – moondaisy
是的,我需要调用一个无参数的构造函数。它工作的方式太。谢谢你 –