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

时间:2013-05-08 14:44:22

标签: c++ function overloading

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

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下不确定是什么导致它我看了一会儿现在似乎找不到错误。也许有人会帮忙?

3 个答案:

答案 0 :(得分:4)

在标题中你有:

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与标题签名不匹配。

答案 1 :(得分:1)

你在类声明中有这个构造函数:

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)

两个参数列表中的参数类型必须匹配。

答案 2 :(得分:1)

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

在你的类的头文件中不存在,头文件有5个参数,但你在cpp文件中有6个,参数类型似乎不匹配,