void makeWithdrawal(double amount)
balance -= amount;
// deposit is the same.
now I can't seem to make a withdrawal. The program compiles, and I can type in a value to deposit/withdraw, but the actual deposit and withdrawal never happens.
That you have multiple banks with just one account doesn't seem to be right. Normally you have a bank where you find the account according to a number.
The question is what does getAccount() return here:
bank[index].getAccount().makeWithdrawal(amount);
if it returns a copy only that copy will be changed not the object within the class. So please show the entire getAccount() function.
So how would I go about calling an account[] from my bank "container" class?
I keep getting errors. Here's the bank.h and bank.cpp
bank.h
1 2 3 4 5 6 7 8 9 10 11 12 13
class Bank
{
private:
Account account[25];
public:
int openAccount(int, int);
int closeAccount(int);
void setAccount(Account []);
Account getAccount() const;
};
You have some design problems in your Bank class.
1) Wouldn't it be a good idea to keep track of how many accounts there are?
2) openAcount requires number of accounts and MAX_ACCTS as arguments. These should be variables private to the Bank class.
3) Ditto for closeAccount. BTW, which account are you trying to close?
4) setAccount() requires an array of accounts to be passed in. Why are you maintaining accounts in two places? How do you know how many accounts are in acct[]?
5) getAccount says it returns a single account, but you're retrying to return an arrray of accounts.
I strongly recommend you use std::vector<Account> to maintain your list of accounts.
ignore openAccount and closeAccount for now, those are unrelated and haven't been coded. We havent learned vectors so I cant use those.
Here's the complete hierarchy. What I'm trying to do is manipulate the balance of an account using makeWithdrawal and makeDeposit. An account has a balance, and a bank has a certain number of accounts. How would I manipulate the account balance in main? How do I call an account[] that is within the bank class?
bank.h
1 2 3 4 5 6 7 8 9 10 11 12 13
class Bank
{
private:
Account account[25];
public:
int openAccount(int, int);
int closeAccount(int);
void setAccount(Account []);
Account getAccount() const;
};