Docsity

Object Oriented Design - Midterm Exam | CSE 687, Exams of Engineering

Toggle sidebar
bg1
CSE687 Object Oriented Design Midterm #4 Spring 2005
Midterm #4
Name:_________________________________ SUID:____________________
This is a closed book examination. Please place all your books on the
floor beside you. You may keep one page of notes on your desktop in
addition to this exam package. All examinations will be collected
promptly at the end of the class period. Please be prepared to quickly
hand in your examination at that time.
If you have any questions, please do not leave your seat. Raise your
hand and I will come to your desk to discuss your question. I will
answer all questions about the meaning of the wording of any
question. I may choose not to answer other questions.
You will find it helpful to review all questions before beginning. All
questions are given equal weight for grading, but not all questions
have the same difficulty. Therefore, it is very much to your advantage
to answer first those questions you believe to be easiest.
pf3
pf4
pf5
pf8
pf9
pfa

Partial preview of the text

Download Object Oriented Design - Midterm Exam | CSE 687 and more Exams Engineering in PDF only on Docsity!

Midterm # Name:_________________________________ SUID:____________________ This is a closed book examination. Please place all your books on the floor beside you. You may keep one page of notes on your desktop in addition to this exam package. All examinations will be collected promptly at the end of the class period. Please be prepared to quickly hand in your examination at that time. If you have any questions, please do not leave your seat. Raise your hand and I will come to your desk to discuss your question. I will answer all questions about the meaning of the wording of any question. I may choose not to answer other questions. You will find it helpful to review all questions before beginning. All questions are given equal weight for grading, but not all questions have the same difficulty. Therefore, it is very much to your advantage to answer first those questions you believe to be easiest.

  1. Provide a class declaration that represents your design of a smart pointer class. A smart pointer provides a public interface like that of a standard C++ pointer. However, it also provides management of the object pointed to, making sure that the object is de-allocated when the smart pointer goes out of scope. Your class should manage single instances of more than one type^1. (^1) But only one type for each smartPtr declaration.
  1. Write the code for a functor class template that takes a function pointer as a template argument and invokes it. Show how you would declare and use an instance of this class for the function: void fun(const X& x); where X is some previously defined class. Your class should work for any function of a single argument of any type. Suggest a way you can extend this to functions with more than one argument.
  1. What does the keyword inline mean? Please describe the differences in compiled code for functions that are qualified as inline and those that are not. What does use of the inline keyword have to do with placement of the function’s code? Be as precise and complete as you can.
  1. Write C++ code to serialize^2 the list, below, to a stream, and to retrieve it from the stream. Show how to use that code to send the state of the list to a file. std::list< std::string > files; (^2) In this context, serialize means to map the state of an object, list in this case, to a string or file in such manner that the serialized state can be reconstituted as the state of a newly created object.
  1. You are asked to draw a UML class diagram that represents your design for Project #2^3. Describe all the types of class relationships illustrated by the diagram. (^3) The Project #2 statement is appended to this exam packet.
  1. Draw a diagram that illustrates how base and derived classes use their virtual function pointer tables to support polymorphic binding. Show how instances access their vtables and how virtual functions are dispatched.
  1. State the Liskov Substitution Principle. How did it (or should it) apply to your design for Project #2?