Hello
I am designing a bank account program to retouch on where I left C++ at and am having a few problems. I wish to have a unique account number for each bank account which is represented by an object e.g. account1, account2, account3. I am struggling to implement something which will make the account numbers unique because i do not know how to track the already previously stated account numbers.
class bankAccount
{
public:
bankAccount();
~bankAccount() {}
int getNumber() { return accountNumber; }
int getBalance() { return accountBalance; }
private:
int accountNumber;
int accountBalance;
int setAccountNumber();
int lastAccountNumber();
};
Above is my class decleration, and as you can see I was going to try and put in something that made a variable in each object with the previous accountNumber and then use a simple increment function to make it go up once each time a new account was made. I am decieded that this is probably not the best way, and there must be a way to do it using refrences/pointers and overiding the ++ operator to increment the accountNumber.
Any help on the matter or advice in which direction to go would be greatly appreicated