这是我的代码:
class package
{
protected:
string name;
string city;
string state;
int zip;
double weight;
double costPerOunce;
public:
package::package(string Name, string City, string State, int Zip, double Weight, double CostPerOunce):
name(Name), city(City), state(State),
zip(Zip), weight(Weight), costPerOunce(CostPerOunce)
{
}
double calculateCost()
{
return (weight * costPerOunce);
}
};
class twoDayPackage: public package
{
protected:
double flatFee;
public:
twoDayPackage::twoDayPackage(double FlatFee):
flatFee(FlatFee)
{
}
double calculateCost()
{
return (weight * costPerOunce) + flatFee;
}
};
int main()
{
system ("pause");
return 0;
}
我尝试运行此代码,我得到的错误如下:错误 C2512:'package':没有适当的默认构造函数可用
该错误与基类构造函数的继承有关,但我不知道为什么代码没有运行。请帮我。