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

标签 c++ function overloading

highInterestChecking header :

#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

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);
}

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

最佳答案

在标题中你有:

highInterestChecking(std::string =" ",int = 0, double = 0.00, double = 0.00, double = 0.00);

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

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

                                                                                ^^^^^^^^^^^

它接受 6 个参数。似乎 int numCheck 与 header 签名不匹配。

关于c++:没有重载函数的实例,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16443670/

相关文章:

python - 将实现特定的 C++ char 与 Python 中的 uint32_t 转换相匹配

javascript - 如何从 javascript/google 应用程序脚本中的外部函数和同级函数调用函数

C++,正确的复制运算符重载

java - 在 Java 中重写方法有哪些不同的方式?

c++ - 如何将 QString 拆分成单个字符并创建一个新字符?

c++ - 提高 C++ 中 ifstream 的性能

c++ - 将汇编代码移植到 C++

java - 如何遍历 Java 中函数返回的数组

javascript - 以 JSON 格式返回 HTML 并调用函数

c# - .Net继承和方法重载