1
h11
CS32 F18
Name:
(as it would appear on official course roster)
Umail address: @umail.ucsb.edu
Optional: name you wish to be called
if different from name above.
Optional: name of "homework buddy"
(leaving this blank signifies "I worked alone"

h11: Inheritance and Derived Classes

ready? assigned due points
true Tue 10/30 08:00AM Tue 11/06 02:00PM

You may collaborate on this homework with AT MOST one person, an optional "homework buddy".

MAY ONLY BE TURNED IN IN THE LECTURE LISTED ABOVE AS THE DUE DATE,
OR IF APPLICABLE, SUBMITTED ON GRADESCOPE. There is NO MAKEUP for missed assignments;
in place of that, we drop the four lowest scores (if you have zeros, those are the four lowest scores).


Reading: Inheritance and Derived Classes, PS 15.1, 15.2, DS 14.1

  1. (10 pts) Fill in the information in the header. The following are required to get the 10 "participation" points.
    • Filling in your name and umail address.

    Also: For paper submission PLEASE submit on ONE SHEET OF PAPER, double-sided if at all possible. If you must submit on two printed sheets write name on BOTH sheets and no staples, paperclips, or folded corners.

  2. For each statement, indicate if it is True or False by circling T or F. If you need to cross out an answer, be sure that your final answer is clear and unambigous—otherwise it will receive no credit.

    (3 pts) An object of a derived class has access to the public methods of its base class T F
    (3 pts) An object of a base class has access to the private helper methods of its derived class T F
    (3 pts) Destructors are not inherited by derived classes T F
    (3 pts) An object of a base class has access to the private helper methods of its derived class T F
    (3 pts) An object of a derived class inherits the copy constructor of its base class T F
    (3 pts) Operators are passed down inheritance hierarchies T F
    (3 pts) Destructors in derived classes are called after their base class calls its destructor T F
    (3 pts) Constructors of base classes are accessible by derived classes T F
  3. Assume there is a class called Student that has private member variables {string name, int perm}. Assume that Student has getters and setters for each of these data members getName, setName, getPerm and setPerm, and a constructor that takes name and perm as parameters. Assume that the class is declare in file student.h

    1. (8 pts) Write the contents of a .h file for a derived a class called CmpscStudent that inherits from Student and has additional data members including {string ugradDegreeType, bool graduateStudent}. Include prototypes for a public constructor that initializes all of the data members of CmpscStudent as well as getters (but not setters) for the additional data members of CmpscStudent. Do not implement these constructors and method "inline".
       
    2. (8 pts) Write the function definition for the constructor CmpscStudent that takes as its parameters all of the data members of CmpscStudent, and fully initializes the object being constructed, as it would appears in the .cpp file.