“没有适当的默认构造函数可用”在Visual C ++中的错误 [英] "No appropriate default constructor available" error in Visual C++
本文介绍了“没有适当的默认构造函数可用”在Visual C ++中的错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我不明白。我一直盯着代码三个小时的代码,我看不到问题。
I don't get it. I've been staring at the code the code for three hours and I can't see the problem.
我创建的类TwoDayPackage派生自class
The class I'm creating, called TwoDayPackage is derived from a class called Package.
这是我如何定义构造函数:
This is how I defined the constructor:
TwoDayPackage(string, string, string, string, int, string, string, string, string, int, float, float, float);
这是我如何实现构造函数:
This is how I implement the constructor:
TwoDayPackage::TwoDayPackage(string sName, string sAddress, string sState, string sCountry, int sZIP, string rName, string rAddress, string rState, string rCountry, int rZIP, float weight, float cost, float flat)
{
Package::Package(sName, sAddress, sState, sCountry, sZIP, rName, rAddress, rState, rCountry, rZIP, weight, cost);
flatRate = flat;
}
这是我在我的main函数中使用它。
This is how i use it in my main function.
TwoDayPackage pack2(senderName, senderAddress, senderState, senderCountry, senderZIP, receipientName, receipientAddress, receipientState, receipientCountry, receipientZIP, weight, cost, flat);
我知道我的参数列表很长,有一个原因。
感谢。
I know my argument list is pretty long, there's a reason for that. Thanks.
推荐答案
应使用:
TwoDayPackage::TwoDayPackage(string sName, string sAddress, string sState, string sCountry, int sZIP, string rName, string rAddress, string rState, string rCountry, int rZIP, float weight, float cost, float flat)
:Package(sName, sAddress, sState, sCountry, sZIP, rName, rAddress, rState, rCountry, rZIP, weight, cost)
{
flatRate = flat;
}
这篇关于“没有适当的默认构造函数可用”在Visual C ++中的错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文