Bank Account help!

So I'm doing a bank account program and reading the information for the accounts from a txt file. The program reads the info, decides whether it fits the criteria of an account and puts it into a vector of accounts. Each time it adds an account the account is assigned an account number, so I read from the txt file with a sstream and i can't seem to get it so the account number increases as an account is added!!! Please help I've been stuck on this for a while.

here is the code:

#include "bank.h"
#include "Checking.h"
#include "CheckingPlus.h"
#include "CheckingPlusPlus.h"
#include "Savings.h"
#include "SavingsPlus.h"
#include "CD.h"


Bank::Bank()
{
vector<AccountInterface*>allAccounts;
time = 0;
}
Bank::~Bank(){}

bool Bank::openAnAccount(string info)
{

AccountInterface* account;
stringstream ss;
string accountType;
double balance;
int accountNumber = 0;
string name;
ss << info;
ss >> accountType >> balance >> name;

if (!ss.eof())
{
return false;
}
else if (ss.fail())
{
return false;
}
else if (ss.eof())
{
if (balance > 0)
{
if (accountType == "Checking" || accountType == "Checking+" || accountType == "Checking++" || accountType == "Savings" || accountType == "Savings+" || accountType == "CD")
{
if (accountType == "Checking")
{
account = new Checking(accountNumber, balance, name);
}
if (accountType == "Checking+")
{
if (balance >= 300)
{
account = new CheckingPlus(accountNumber, balance, name);
}
else
{
return false;
}
}
if (accountType == "Checking++")
{
if (balance >= 800)
{
account = new CheckingPlusPlus(accountNumber, balance, name);
}
else
{
return false;
}
}
if (accountType == "Savings")
{
account = new Savings(accountNumber, balance, name);
}
if (accountType == "Savings+")
{
if (balance >= 1000)
{
account = new SavingsPlus(accountNumber, balance, name);
}
else
{
return false;
}
}
if (accountType == "CD")
{
account = new CD(accountNumber, balance, name);
}

allAccounts.push_back(account);
return true;
}

}

}
return false;
}
Topic archived. No new replies allowed.