Usually, it is a good idea to draw a class-hierarchy diagram, such as the following, to see how your classes fit together. All arrows represent subclass-to-superclass relations:
*-----------------------* | container | | percent_loaded | *-----------------------* ^ ^ | | *--------* *--------* | | *-------------------* *-------------------* *--------------------* | box | | cylinder | | railroad_car | | volume function | | volume function | | age function | | height | | radius | | year_built | | width | | length | | | | length | | | | | *-------------------* *-------------------* *--------------------* ^ ^ ^ ^ ^ ^ | | | | | | | *----------------------------------------* | | | | | | *---------------------* | | | | | | *----------* | | | | | | | *----------* *----------* *----------* *----------* | box_car | | tank_car | | engine | | caboose | *----------* *----------* *----------* *----------*
Such a class-hierarchy diagram helps you to see how to distribute member variables and member functions among the classes in the hierarchy. Such a class-hierarchy diagram can also expose semantic risks of the sort described in Segment 224.