C++ c++;:没有重载函数的实例
高兴趣检查标题:C++ c++;:没有重载函数的实例,c++,function,overloading,C++,Function,Overloading,高兴趣检查标题: #ifndef H_highInterestChecking #define H_highInterestChecking #include "noservicechargechecking.h" #include <string> class highInterestChecking: public noServiceChargeChecking { public: highInterestChecking(std::string =" ",int =
#ifndef H_highInterestChecking
#define H_highInterestChecking
#include "noservicechargechecking.h"
#include <string>
class highInterestChecking: public noServiceChargeChecking
{
public:
highInterestChecking(std::string =" ",int = 0, double = 0.00, double = 0.00, double = 0.00);
};
#endif
我有一个错误“没有重载函数的实例”。在构造函数名HighInterestCheck下,在cpp文件中检查不确定是什么导致了它。我看了一会儿,现在似乎找不到错误。也许有人会帮忙?在标题中,您有:
highInterestChecking(std::string =" ",int = 0, double = 0.00, double = 0.00, double = 0.00);
highInterestChecking::highInterestChecking(string name, int acct, double bal, int numCheck, double min, double i)
^^^^^^^^^^^
它接受源文件中的5
参数:
highInterestChecking(std::string =" ",int = 0, double = 0.00, double = 0.00, double = 0.00);
highInterestChecking::highInterestChecking(string name, int acct, double bal, int numCheck, double min, double i)
^^^^^^^^^^^
它接受
6个
参数。似乎int numCheck
与头签名不匹配。在类声明中有此构造函数:
highInterestChecking(std::string =" ",int = 0, double = 0.00, double = 0.00, double = 0.00);
在类定义中有一个:
highInterestChecking::highInterestChecking(string name, int acct, double bal, int numCheck, double min, double i)
两个参数列表中的参数类型必须匹配
highInterestChecking::highInterestChecking(string name, int acct,
double bal, int numCheck, double min, double i)
//^^^
在类的头文件中不存在,头文件有5个参数,但在cpp文件中有6个参数,参数类型似乎不匹配,您需要变量名。您正在将值赋给类型
double
一个参数,就像它是参数列表中的变量一样。@RageD:不,可以。他提供了一个没有名字的参数,然后是该参数的默认值。您在函数声明中忘记了int-numCheck
参数。在头文件中,可以这样做来设置默认参数。@Axilles:听到这个消息我很难过;这不是堆栈溢出应该如何工作的。勇敢地站起来!如果你被否决,这是一个学习的机会;在这种情况下,你会被投票,甚至可能被接受!这是误导。它们不需要在词汇上是“相同”的,尽管它们必须描述相同的参数类型列表。谢谢你,哈哈,我怎么会错过我发誓我数了参数,我的眼睛开始动了lol@EricOudin这表明您的参数太多。你可以考虑把其中的一些捆绑成一个类。