{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

final-draft

# final-draft - EECS 280 Final Fall 2005 This is a...

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

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

View Full Document
Uniqname:________________________________________________________________________________ EECS 280 Fall 2005 2
Uniqname:________________________________________________________________________________ EECS 280 Fall 2005 3 Problem 1 _________ out of 16 Problem 2 _________ out of 16 Problem 2 _________ out of 20 Problem 3 _________ out of 24 Problem 4 _________ out of 24 Total: ________ out of 100

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

View Full Document
Uniqname:________________________________________________________________________________ EECS 280 Fall 2005 4 1 Class Mechanics In this question, you will be asked to state properties about the following classes: class Foo { int foo; public: virtual int lcm(int x, int y) = 0; }; class Bar : public Foo { protected: int bar; public: int lcm(int x, int y); // REQUIRES: x and y are positive integers. // EFFECTS: returns the least common multiple of x and y. virtual int do_stuff(Foo& f); // EFFECTS: does "stuff" }; class NonPositiveNumber {}; class Baz : public Bar { int baz; public: int lcm(int x, int y); // EFFECTS: throws NonPositiveNumber if x or y is <= 0 // returns the least-common multiple of x // and y otherwise. int greater(int x, int y); // EFFECTS: Returns the larger of x, y. }; class Bat: public Bar { private: int bat; public: int do_stuff(Foo& f) { return Bar::do_stuff(f); } };
Uniqname:________________________________________________________________________________ EECS 280 Fall 2005 5 1.a Visibility Assume that the following four statements are added to the method Bat::do_stuff above: (a) foo = 3; (b) bar = 3; (c) bat = 3; (d) baz = 3; For each statement, state whether the statement will produce a compiler error when the program is compiled by a standards-compliant compiler 1.b Subtypes Is Baz a subtype of Bar? Why or why not?

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

View Full Document
Uniqname:________________________________________________________________________________ EECS 280 Fall 2005 6 Is Bat a subtype of Bar? Why or why not?
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 18

final-draft - EECS 280 Final Fall 2005 This is a...

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

View Full Document
Ask a homework question - tutors are online