我試圖解決這個錯誤,但我沒有做什麼..得到錯誤的呼叫沒有匹配功能,飛艇飛艇
#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
是的,我需要調用一個無參數的構造函數。它工作的方式太。謝謝你 –