
CSE687 Object Oriented DesignMidTerm Makeup Spring 2007
Midterm Makeup – Take Home Examination
1. Implement a function that accepts an STL container and displays
string representations of the first N elements on the first line, the
elements from N+1 to 2N on the second line, and so on. Please
format your output so each element is written into a fixed size field.
Your function should compute the field size, allowing for spaces
between fields, so that N fields fill, without wrapping, a single line.
Your function must be able to accept more than one type of
container, say either a list or a vector, but you are required to show
only that it is correct for a vector. Under what circumstances will
your implementation fail to compile?
2. What are the main design strategies used in Object Oriented
Design?
3. Write all the code for a class that implements the std::istream
interface and supplies a member function that supports pushing
back any number of characters previously retrieved from the
stream. All other functions behave as in the istream class itself.
Embed this class in a CSE687 namespace. Please explore
overriding the std::streambuf class to accomplish this.
4. Draw a UML class diagram that represents your design for Project
#4. Discuss how the Dependency Inversion Principle could apply to
this design. The question does not ask if you did, but rather, how
could you apply DIP for this design.
5. Please provide the definition of a function that accepts an array of
pointers to functions with the signature int func(X &x), invokes each
of the functions, and returns the sum of the computed values.
6. Given the code fragments below, where the ellipsis (…) represents
code that has not been disclosed to you:
class X { … }; class Y { public: explicit Y(const X& x); … };
what can you say about the compilation and execution of each of
the following statements? Describe each of the operations that
occur as this code executes.
Y func(Y y) { … }
X x;
Y y = func(Y(x));