c109s00t1 - CSc 109 Test 1 1 March 2000 >[SUGGESTED...

Info icon This preview shows pages 1–2. Sign up to view the full content.

CSc 109 Test 1 1 March 2000 >>>>>>>>>>>>>>[SUGGESTED ANSWERS]<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 1. Class Rect below is meant to represent a rectangle. Write the declaration and definition of a subclass of Rect called Box, which represents a 3-dimensional box. You should note that Rect has no protected members and that Box should have only one more data member beyond those it inherits (len, wid). Including your declaration and definition (code) should allow the following statement to compile. cout<<"The volume of the 2x3x4 box is "<<box(2,3,4).volume()<<endl; class Rect{ public: Rect(); Rect(double le,double wi); //create a box of length le and width wi Rect(const Rect & r); double area(); private: double len, wid; }; class Box : public Rect{ public: Box(const Box & b); Box(double le,double wi, double ht); double volume(); private: double high; }; Box::Box(double le, double wi, double ht):Rect(le,wi){ high=ht; } Box::Box(const Box &b):Rect(b){ high=b.high; } double Box::volume(){ return area()*high; } 2. For the Simpletron program below, fill in the values in the table
Image of page 1

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

Image of page 2
This is the end of the preview. Sign up to access the rest of the document.
  • Spring '08
  • Kay
  • United States Declaration of Independence, The Table, The Declaration, prog prog prog

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    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.

    Student Picture

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

  • Left Quote Icon

    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.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    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.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern