Bank Account exercise - What am I doing wrong?

I know that I probably did a very noob mistake. I read and read this code up but have no idea what's wrong.

The compiler says that the prototype for Account::credit( int ) does not match.

So what can I do?


I'm following the How To Program C++ by Deitel 8th edition.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include "Account.h"
#include <iostream>
using namespace std;

Account::Account( int initBalance )
{
    if(initBalance >= 0)
        currentBalance = initBalance;
    else
    {
        currentBalance = 0;
        cout << "The initial value is invalid. ";
    }
}
Account::credit(int amount)
{
    currentBalance += amount;
}

Account::debit(int amount)
{
    if( amount > currentBalance)
    {
        cout << "Debit amount excceed account balance.";
    }
    else
        currentBalance -= amount;
}

Account::getBalance();
{
    return currentBalance;
}
// How I define the class...

class Account
{
public:
    Account ( int  );
    void credit( int );
    void debit( int );
    int getBalance();
private:
    int currentBalance;

};
 
1
2
3
4
Account::credit(int amount)
{
    currentBalance += amount;
}


You haven't specified the return type in the method definition here. Or, indeed, in any of your other method definitions.
Thanks, you helped a lot
You're welcome :)
Topic archived. No new replies allowed.