Inheritance

Ineritance can support the idea of type/subtype and is the only way in C++ to relate two classes directly. However, objects can have many other relationships. Sketch C++ class structures with suitable members to support the following object relationships:

1.      a colored object

2.      one object being a member of a set of like objects

3.      one object being inside another

4.      one object touching another

5.      one object helping another carry out some task

6.      one object following another's movements

Notes

·        This is an exercise in object-oriented analysis and representation of this analysis in an object-oriented language.

·        You can use any feature of C++ you think useful, but in each case, state the reasons for making the choices you did.

·        To focus your ideas, think about implementing appropriate accessor functions in each case. e.g. a function to return the color of an object for part 1.

Due Date

April 17th. in class.