Download the file bank.cpp, add it to a
project,
study the code and run it.
You must understand this original code completely before you modify
it.
After you modify it, it should produce the very same output!
Here is the output:
Customer: Smith Balance: $100.00
After $400.00 Deposit
Customer: Smith Balance: $500.00
Thinking about this transaction ...
$1000.00 Check
This transaction is not OK
Thinking about this transaction ...
$50.00 Check
This transaction is OK
After the transaction
Customer: Smith Balance: $450.00
Undoing following transaction:
$50.00 Check
After undoing
Customer: Smith Balance: $500.00
Press any key to continue
Make the following changes:
Create 2 structs:
one for a bank
account,
one for a
banking
transaction
Each struct will have 2 members.
Rewrite the program so that it uses the 2 structs
whenever possible.
(If you have missed lecture, look at the class web site to see what
we did.)
Rewriting the program with structs will require replacing many variable
and
parameters declarations as well as removing reference parameters
(&)
and
adding return types/return statements. Here are some examples
of code written
with and without structs.
When you are done, there will be no reference parameters (&) remaining.
All the init routines will have return
types,
as will any function that modifies an account.
The return statement will be used to send back the new or modified
thing (account or transaction).