【发布时间】:2013-05-08 14:44:22
【问题描述】:
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 下不确定是什么原因导致它我看了一会儿现在似乎找不到错误。也许有人会帮忙?
【问题讨论】:
-
你需要变量名。您正在为
double类型的参数赋值,就好像它是参数列表中的变量一样。 -
@RageD:不,没关系。他提供了一个没有名称的参数,然后是该参数的默认值。
-
你忘记了函数声明中的
int numCheck参数。 -
在头文件中设置默认参数是可以的。
-
@Axilles:很遗憾听到这个消息;这不是 Stack Overflow 应该如何工作的。勇敢发帖!如果你被否决,这是一个学习机会;在这种情况下,您可能会获得支持甚至被接受!
标签: c++ function overloading