1. C::J N(D), R::E L (B) if N!=L print no relation else if C and R are related in inheritance if N=L if B and D are related in subtyping AND J and E are related in subtyping then print 'overriding combination' (typesafe or typeunsafe+exceptions) else print 'overloading' else print 'no relation' * in table form classes function name i/p types o/p types inference related same related related no X X X not related yes X X X not related yes 1 0 X overloading yes 1 X 0 overloading yes 1 1 1 typesafe or static-unsafe overriding combinations overriding combinations wrt S1 f(T1) ^ S2 f(T2) i/p o/p static-safe? ------------------------------------------------ down(T1->T2) up(S1<-S2) yes down down(S1->S2) no, RTTI+exceptions up (T1<-T2) down no RTTI+exceptions up up no RTTI+exceptions 2. (a) by calling super class's member functions from inside subclass, by using super class's member variables (protected) in subclass. (b) by exporting superclass's member functions as if they are provided by subclass. (is_a relation) (c) code written in terms of superclass is reusable across the instances of subclasses through subsumption/polymorhpism. 3. An example contract coin box has: ticket value buttons, coin slot, ticket/coin pickup tray member precondition postcondition action if precondition is violated selectTicketValue Pre1: coin cache >= ticket ticket printed, try with Pre2. value change kept in cache, ticket value unselect selectTicketValue Pre2: coinbox is adequately ticket value remembered empty, cache>=val: empty for needed value try with Pre2. i.e. selected minus in cache not empty: flag coinboxfull indicator insertCoin ticket value selected ticket printed if coin cache >= ticket value, change value cached in:ticket value unselect loadTickets ... (optional) Implementation is expected in Java or C++ with assertions, or in Eiffel with post and preconditions