$29
CSCI251/CSCI851 Advanced Programming
Laboratory Exercise 8 (Week 9)
Note that lab exercises marked with a * are effectively extension exercises.
1 Task One: Warm–up exercises
1. Consider the file Tracing.cpp. Determine the order in which the constructors and destructors are
called. Write down the sequence of line numbers associated with the constructors and destructors
in the order they are used.
2. * What is the idea of the mutable data member? Write some code illustrating the idea.
3. How has the rounding of a negative quotient in division changed in C++11? Why does this matter?
4. The following tasks relate to inheritance. For each of the classes you should provide sufficient
functionality to test your understanding of the relationships between the classes. You should, in
particular, see how you can use constructors across classes.
(a) Define a base class Transportation.
(b) Define three derived classes, SeaTransport, LandTransport, and AirTransport.
(c) Inheritance can occur across multiple levels. Define Car and Canoe as classes derived from
appropriate classes.
(d) It’s possible to have multiple inheritance in C++. Define HoverCraft as derived from two
appropriate classes.
2 Task Two: The Three Little Pigs
Carry out these tasks for The Three Little Pigs. Ideally you should be discussing this with other
people.
1. Write a timeline identifying the events in the story.
2. Identify appropriate objects/classes and attributes/behaviours for those classes.
3. Sketch a class diagram showing the classes and appropriate relationships. This may be an somewhat
iterative process with multiple versions.
4. Write code to implement the identified structures.
5. Write main() function(s) which when run will approximate the events of the story, or similar stories.
It can be interactive if you like, to cover variations on the stories.
c Luke McAven, SCIT-EIS-UOW, 2019.
1