eecs280f13_FinalExam

# eecs280f13_FinalExam - uniqname EECS280FinalExam Fall2013...

This preview shows pages 1–6. Sign up to view the full content.

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

View Full Document
uniqname: _________________________ Do not write here. Cover page _________ out of 1 Staff Initials Problem 1 _________ out of 19 Problem 2 _________ out of 20 Problem 3 _________ out of 20 Problem 4 _________ out of 20 Problem 5 _________ out of 20 Total: _________ out of 100 EECS 280 Fall 2013 2/25
uniqname: _________________________ Problem 1: Short Answer (19 points) PART A: Big Three (10 points) The code below will generate 10 lines of output. These 10 lines have been given to you out of order. Arrange them in the order they would be generated in. (NOTE: it’s OK to tear out this page) class BigThree { private: int i; public: BigThree(int i_in) : i(i_in) { cout << "Constructor: " << i << endl; } BigThree(const BigThree &o) : i(o.i) { cout << "Copy constructor: " << i << endl; } BigThree& operator=(const BigThree &o) { cout << "Assignment operator: " <<o.i<< "­>" << i << endl; i = o.i; return *this; } ~BigThree() { cout << "Destructor: " << i << endl; } void test(BigThree a, BigThree &b) { cout<<"I got my 10 points!"<<endl; } int main() { BigThree var1(1); BigThree var2(2); BigThree other = var2; other = var1; test(var1, var2); } EECS 280 Fall 2013 3/25

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

View Full Document
uniqname: _________________________ Incorrect order of output: Write the correct order of output: Copy constructor: 2 Constructor: 2 Copy constructor: 1 Destructor: 1 Destructor: 2 Assignment operator: 1­>2 Constructor: 1 Destructor: 1 I got my 10 points! Destructor: 1 EECS 280 Fall 2013 4/25
uniqname: _________________________ Part B: Subclasses and Subtypes, and Virtual Functions (5 points) (NOTE: it’s OK to tear out this page) class Ball { public: virtual int toss(int target_distance, int target_height); // REQUIRES: target_height is greater 0 // EFFECTS: returns the actual distance traveled, // which is <= target_distance virtual bool bounces(); // EFFECTS: return true if ball is inflated, false if not } class Football : public Ball { public:

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

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern