
CSE687 Object Oriented Design Midterm #4 Spring 2004
1. Given the class declaration:
class X : public Y { … };
What can you say about the global function declarations on the
left? What will happen when they are each compiled or invoked as
shown on the right?
myFun1(Y y); myFun1(X());
myFun2(Y& y); myFun2(X());
myFun3(const Y& y); myFun3(X());
2. Why is deferred binding important?
3. Given the class declarations:
class A
{
public: virtual void mf1(int); virtual int mf2(); void mf3(); …
};
class B : public A
{
public: int mf2(); virtual void mf4(); …
};
What constraints on the unspecified code, shown by the ellipses …,
are necessary to ensure that the Liskov Substitution Principle is
satisfied?
4. Sketch a UML class diagram that represents your design of a
network-based digital library. That is, the program supports the
display of brief descriptions of indexed items, organized into
categories. It also supports the downloading of items from the
library. You don’t need to know anything about network
programming or windows programming for this task. Just focus on
the design aspects of the question.
5. Write a declaration for a class that represents a graph. A graph
consists of a collection of nodes, connected to one-another by
edges. Usually a node is connected to only a few of the other
nodes within the graph. Each node and each edge have an
associated type, specified by the user of the class.