2

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

4

3 回答 3

5

In the header you have:

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

Which takes 5 arguments, In the source file you have:

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

                                                                                ^^^^^^^^^^^

which takes 6 arguments. It seems like int numCheck does not match the header signature.

于 2013-05-08T14:47:05.133 回答
2

You have this constructor in the class declaration:

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

and this one in the class definition:

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

The parameter types from both parameter lists must match.

于 2013-05-08T14:48:08.183 回答
2
  highInterestChecking::highInterestChecking(string name, int acct, 
                           double bal, int numCheck, double min, double i)
                                       //^^^

does not exist in your class's header file, header file has 5 parameters, but you have 6 in cpp file, parameter type seems mismatched,

于 2013-05-08T14:48:30.830 回答