Banking Classes

l
Last edited on
;
Last edited on
Use code tags and sane indentation, please: http://www.cplusplus.com/articles/jEywvCM9/
Im sorry about that
Please use the code format tags to format your code, there's a tag palette on the lower right part of the screen.

It's a reasonable start.

Using a static to generate back account numbers is a good idea. However, you only want to do that when you create a new account, not when you construct a BankAccount object.

That function should be:
1
2
3
int BankAccount::getAccountNumber() const {
    return accountNumber;
}
Sorry about that.

so you want me to replace lines 22-23 with
1
2
3
int BankAccount::getAccountNumber() const {
    return accountNumber;
}


Correct?
Yes. It replaces lines 22-30.

'string number' was not on list, but balance and rate were (lines 9-20).

The static accountNumberGenerator has to be initialized separately.


Lines 36-41 begin a setName(). Your class, however, has BankAccount::setName(string) (with a case typo). It is better to not have IO within that function, so do pass the string as parameter.


As kbw said, an active account and an object are probably not one and the same. You have to create an array of objects. Two options, (1) you have all data for all accounts before you create those accounts, or (2) accounts start without owners and are later taken into use one by one.

For the latter, think about pointers. They have either value 0 or point to some memory. That 0 / NULL / nullptr is a convention to show invalid pointer. Now think about the accountNumber.
Topic archived. No new replies allowed.