My data structure is:
vector <pair <int, vector <SavingsAccount*>>> accVec;
where the int
is the bank account number.
My goal is to check if the account number input by the user matches any int
within any pair in the accVec
vector.
In main, I'm using something like:
do {
iter = find_if (accVec.begin(), accVec.end(), findAccID);
if (iter == accVec.end()) {
cout << endl << "ERROR: Account Does Not Exist. Try Again." << endl;
}
} while (iter == accVec.end());
Function:
bool findAccID(pair <int, vector <SavingsAccount*>> accPair) {
static int i = 0, accID;
if (i == 0) {
cout << endl << "Enter The Account Number In Which You Want To Deposit: ";
cin >> accID;
i++;
}
if (accID == accPair.first) {
return true;
}
return false;
}
I am asking the user for the account number inside the function because I could not find a way to pass the accID
as a parameter from main()
. I want the question to repeat as long as the user types the wrong account number.
Any suggestions?