Working with C++ Classes and Objects 701
BD3
- If a guppyinherits from a fishclass, then the fishis said to be the
a. base class
b. subclass
c. Neither the base class nor the subclass - What would be the header line for the declaration of the guppyclass used in quiz
question 4? - Which executes first, a base class’s constructor or the sub class’s constructor?
- Which executes first, a base class’s destructor or the sub class’s destructor?
Exercises ........................................................................................................
- Create a class that will hold a point. Call the class point. This should contain an x
value and a yvalue that are both private. Use data access members. - Create a class for a circle. The data members can be the circle’s center point and
the circle’s radius. Use the point class from exercise 1 to create the point’s center
data member. - Create a constructor for the circle class in exercise 2. Use zeros as default parame-
ters for the point’s center. Use 1 as the default radius. - Create a public member function that returns the circle’s circumference.
- Write the code for the point class presented at the beginning of today’s lesson.
- Write the code for the line class presented at the beginning of today’s lesson.
- Rewrite the code for the lineclass so that it inherits the point class and extends it
by also storing a length. - Rewrite Listing B4.3 to work for the studentclass instead of the employeeclass.
38 448201x-Bonus3 8/13/02 11:19 AM Page 701