Listings 8.1 to 8.14. "The C++ Workbook" by Wiener and Pinson, Addison-Wesley, 1990.