homework3

homework3 - Homework 3 CSC 4101, Fall 2011 Due: 25 October...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
Homework 3 CSC 4101, Fall 2011 Due: 25 October 2011 1. (10 pts) Suppose we had support for multimethods in Java instead of or in addition to overloading. Explain how you would implement the pretty printer of Project 1 using multimethods instead of having a print() method in each class of the hierarchy. What would be the advantage of using multimeth- ods? You can simply use the same syntax as for overloading and indicate where the multimethod dispatch happens. 2. (10 pts) Suppose we have the following class: class C { / * ... * / public: int foo (); int bar (); }; Also suppose that this class is only available in compiled form, i.e., that it cannot be modified. Now we want to add an alternative implentation that only has a method foo() but that does not have a method bar() and does not inherit the data members from class C . I.e., this new class D would have the structure class D / * ... * / { public: int foo (); }; but it cannot inherit from class C . Suppose we want to maintain a list of objects that can be from either classes
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 12/31/2011 for the course CSC 4101 taught by Professor Kraft,d during the Fall '08 term at LSU.

Page1 / 2

homework3 - Homework 3 CSC 4101, Fall 2011 Due: 25 October...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online