void CMenu::newLoan(){
int sel;
CMortgage * mort;
cout << "Enter the type of loan:" << endl;
cout << "1. Simple Interest" << endl;
cout << "2. Rule of 72" << endl;
cout << "3. Fixed Payment" << endl;
cout << "$ ";
cin >> sel;
switch(sel){
case 1: // Allocating new CSimple: public CMortgage
mort = new CSimple;
mort->getValues();
mort->print();
morts.push_back(mort);
break;
case 2: // Allocating new CSeventyTwo: public CMortgage
mort = new CSeventyTwo;
mort->getValues();
mort->print();
morts.push_back(mort);
break;
case 3: // Allocating new CFixed: public CMortgage
mort = new CFixed;
mort->getValues();
mort->print();
morts.push_back(mort);
break;
default:
cout << "That is not a valid choice!" << endl;
newLoan();
}
}
int CMenu::menu(){
int sel;
cout << "Enter your choice:" << endl;
cout << "1. New Loan" << endl;
cout << "2. Delete Loan" << endl;
cout << "3. Print Loan" << endl;
cout << "4. Edit Loan" << endl;
cout << "5. Exit" << endl;
cout << "$ ";
cin >> sel;
switch(sel){
case 1: // Start up a new mortgage
newLoan();
break;
case 2: // Page iterator to (class scope) list item and delete
selLoan();
delete *it;
morts.erase(it);
it = morts.begin();
break;
case 3: // Page iterator to (class scope) list item and print
selLoan();
(*it)->print();
break;
case 4: // Page iterator to (class scope) list item and edit
selLoan();
editLoan();
break;
case 5: // Return to int main()
return 0;
break;
default:
cout << "That is not a valid choice!" << endl;
}
menu();
}
void CMenu::newLoan(){
int sel;
CMortgage * mort;
cout << "Enter the type of loan:" << endl;
cout << "1. Simple Interest" << endl;
cout << "2. Rule of 72" << endl;
cout << "3. Fixed Payment" << endl;
cout << "$ ";
cin >> sel;
switch(sel){
case 1: // Allocating new CSimple: public CMortgage
mort = new CSimple;
mort->getValues();
mort->print();
morts.push_back(mort);
delete mort;
break;
case 2: // Allocating new CSeventyTwo: public CMortgage
mort = new CSeventyTwo;
mort->getValues();
mort->print();
morts.push_back(mort);
delete mots
break;
case 3: // Allocating new CFixed: public CMortgage
mort = new CFixed;
mort->getValues();
mort->print();
morts.push_back(mort);
delete mort;
break;
default:
cout << "That is not a valid choice!" << endl;
newLoan();
}
}
int CMenu::menu(){
int sel;
cout << "Enter your choice:" << endl;
cout << "1. New Loan" << endl;
cout << "2. Delete Loan" << endl;
cout << "3. Print Loan" << endl;
cout << "4. Edit Loan" << endl;
cout << "5. Exit" << endl;
cout << "$ ";
cin >> sel;
switch(sel){
case 1: // Start up a new mortgage
newLoan();
break;
case 2: // Page iterator to (class scope) list item and delete
selLoan();
delete *it;
morts.erase(it);
it = morts.begin();
break;
case 3: // Page iterator to (class scope) list item and print
selLoan();
(*it)->print();
break;
case 4: // Page iterator to (class scope) list item and edit
selLoan();
editLoan();
break;
case 5: // Return to int main()
return 0;
break;
default:
cout << "That is not a valid choice!" << endl;
}
menu();
}
please define the class of which morts is the object .
I'm not sure but I really dont think that delete *it makes any sense at all. Unless it is a double pointer ** then dereferencing it makes no sense to me
==25978==
==25978== HEAP SUMMARY:
==25978== in use at exit: 0 bytes in 0 blocks
==25978== total heap usage: 34 allocs, 34 frees, 1,190 bytes allocated
==25978==
==25978== All heap blocks were freed -- no leaks are possible
==25978==
==25978== For counts of detected and suppressed errors, rerun with: -v
==25978== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 4 from 4)