Homework #34


This problem is not from your textbook.

In this assignment, you will write short programs in C++ similar to the OOELL examples on pages 175 and 176 of your textbook to illustrate how C++ handles inheritance.

Part A - (20 minutes)
Write one program modeled after the example on page 175 to demonstrate that C++ uses static inheritance for variables.

Part B - (20 minutes)
Write a second program modeled after the example on page 176 to illustrate that C++ uses static inheritance for methods if you do not use the virtual keyword.

Part C - (20 minutes)
Write a third program, using the virtual keyword but otherwise identical to your second program, to demonstrate that C++ uses dynamic method inheritance for methods that are declared as virtual.

The OOELL examples store intermediate results and return them as a list since OOELL doesn't have print statements. You don't have to do this--just use normal C++ output as needed to print out what the different methods return.

In your submitted file, include the following for each of these three programs:


You must log in first before submitting homework assignments.

Instructions on submitting homework is here


Last updated at 9:53 am on Friday, August 27, 2004.