Session Aims and Instructions
Classes in C++
[Savitch 6.2, 7.1; Stroustrup 10.1-2.2,10.3.1; Horstmann 8]
- Slides
- Lab exercise
- Lab exercise solutions (only available after the lab session)
- Model solutions for this lab session:
-
- Yes, the solutions represent the balance as a long (**NOT** floating point!)
number, because floating point numbers lose accuracy and so are never used for
representing money.
See here why floating-point numbers are very bad for
representing money:
https://stackoverflow.com/questions/3730019/why-not-use-double-or-float-to-represent-currency
Here are the SQL data types used in two well-known databases -
check money (decimal is a fixed-point number, so not a floating-point
number, so an integer):
- Can you see how account deposit re-uses the account constructor to implement
itself and how withdraw re-uses deposit?
Never copy-paste code - re-use it!
This page does not appear to be using a
stylesheet. It will be much improved if you use a recent browser that
supports cascading style sheets.