我正在尝试创建一个派生类 CheckingAccount 的 BankAccount 类。我遇到的问题如下:
- CheckingAccount 应该包含一个数据成员来跟踪帐户上进行的提款交易的数量。每当提款时,这个数字应该增加。
- 重写基类,withdraw-money 函数,并添加从账户中扣除交易费用的功能
银行账户.h
class BankAccount {
private:
/* ATTRIBUTES */
int accountNumber;
double balance;
public:
/* METHODS */
BankAccount();
void setAccountNumber( int );
void deposit( double );
int getAccountNumber();
int getBalance();
double withdraw( double );
};
CheckingAccount.h
#include "BankAccount.h"
class CheckingAccount: public BankAccount {
private:
/* ATTRIBUTES */
int withdrawalAmount;
double balance;
/* METHODS */
public:
/* METHODS */
CheckingAccount();
};
CheckingAccount.cpp
#include "CheckingAccount.h"
CheckingAccount::CheckingAccount() {
//Initialize
}
double CheckingAccount::withdraw( double a ) {
//This doesn't work.
}