{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

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 I got my 10 points! 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 { int toss(int target_distance, int target_height);

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 ]}

### Page1 / 25

eecs280f13_FinalExam - uniqname EECS280FinalExam Fall2013...

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

View Full Document
Ask a homework question - tutors are online