So I'm writing an ATM/Bank program using pointers and dynamic memory. Everytime an account is read in, it is allocated with new.
the problem is I'm using a destructor to at the end to delete the entire array as well as any existing accounts. This is giving me issues like crashing and somehow causing my program to print gibberish strings that were read in from a file. If I comment out the destructor I don't get any crash upon quitting and the program doesnt print gibberish. Is this destructor necessary? if it is, how can I fix it? Code below:
It seems Bank::deleteAccount() is deleting wrong account.
The logic seems to be taking out account at index and then delete it, but in fact you deleting account at index + 1, and leaving it in the array.
I think that was the issue. I went back and realized I was moving the array then deleting the account, when I should've been removing the account then moving the array.