-6

I'm trying to make a BankAccount class with derived a class CheckingAccount. The problem I'm having are as follows:

  1. CheckingAccount should contain a data member to keep track of the number of withdrawal transactions made on the account. Whenever a withdrawal is made, this number should be incremented.
  2. Override the base class, withdraw-money function, and add the capability to deduct transaction fees from an account

BankAccount.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.
}
Michael Libman
  • 73
  • 1
  • 10
  • 5
    That's not a description of your *problems*, it's a copy of your *assignment*. Try something and if that doesn't work, you can ask about that. – us2012 Mar 26 '13 at 15:36
  • You didn't declare the prototype of `withdraw()` inside `class CheckingAccount`. – timrau Mar 26 '13 at 15:37
  • I did try something that doesn't work.. Maybe I wasn't clear enough. I don't understand how to use the withdraw function in BankAccount to increment from the CheckingAccount. And I haven't been a student for 3 years now so no... not an assignment for school Fatih. – Michael Libman Mar 26 '13 at 15:44
  • @MichaelLibman I've not seeing anything in your assignment that requires you to use the withdraw function in BankAccount. You are asked to override the withdraw function. You said you tried something that didn't work, as usual it would be helpful if you posted what you tried. It helps us understand what misunderstandings you have. – john Mar 26 '13 at 15:53

1 Answers1

2

Just make withdraw virtual in BankAccount class and declare it in CheckingAccount.

virtual double withdraw( double );
Mikhail Melnik
  • 966
  • 9
  • 19