C++:没有重载函数的实例

Eri*_*din 2 c++ overloading function

highInterestChecking 标题:

#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
Run Code Online (Sandbox Code Playgroud)

highInterestChecking cpp:

#include "highInterestChecking.h"
using std::string;

highInterestChecking::highInterestChecking(string name, int acct, double bal, int numCheck, double min, double i)
{
    bankAccount::setAcctOwnersName(name);
    bankAccount::setAcctNum(acct);
    bankAccount::setBalance(bal);
    checkingAccount::setChecks(numCheck);
    noServiceChargeChecking::setMinBalance(min);
    noServiceChargeChecking::setInterestRate(i);
}
Run Code Online (Sandbox Code Playgroud)

我有错误“没有重载函数的实例”。在 cpp 文件中的构造函数名称 highInterestChecking 下不确定是什么导致它我看了一会儿现在似乎找不到错误。也许有人会帮忙?

Sha*_*our 5

在标题中,您有:

highInterestChecking(std::string =" ",int = 0, double = 0.00, double = 0.00, double = 0.00);
Run Code Online (Sandbox Code Playgroud)

这需要5参数,在源文件中你有:

 highInterestChecking::highInterestChecking(string name, int acct, double bal, int numCheck, double min, double i)

                                                                                ^^^^^^^^^^^
Run Code Online (Sandbox Code Playgroud)

这需要6参数。似乎int numCheck与标头签名不匹配。

  • @EricOudin 这表明您有太多参数。您可以考虑将其中的一些捆绑到一个类中。 (2认同)