So basically what is going on is this. The code works perfectly fine to add the objects into the array. But when I close the accountFile, the entire array becomes NULL. How can I avoid this so that I can use the array for other things?
accounts = new Account*[numAccounts];
for (int i = 0; !accountFile.eof(); i++)
{
if (accountFile >> tempAccountType)
{
if (tempAccountType == "Checking")
{
accountFile >> tempAccountNum >> tempBalance >> tempTransFee;
CheckingAccount tempAccount(tempBalance, tempAccountNum, tempTransFee);
accounts[i] = &tempAccount;
}
else
{
accountFile >> tempAccountNum >> tempBalance >> tempIntRate;
SavingsAccount tempAccount(tempBalance, tempAccountNum, tempIntRate);
accounts[i] = &tempAccount;
}
}
}