Answers for Bonus Day 3
Quiz
- A structure is a special form of the class in C++. The structure’s members are pub-
lic by default. A class’ members are private by default. Note that, if you are using
member functions, you should use a class instead of a structure. - A class is only a definition, so you cannot assign values to it. You can use it to cre-
ate an object. The object can have values assigned to it. - An object is a variable that has been created using a class.
- To instantiate a class means to create an object using the class.
- Classes have characteristics from all three object-oriented features. Classes illus-
trate encapsulation because they contain all the data and functionality in a single
construct. Polymorphism can be seen in the fact that classes can have overlaid
functions including their constructors. Inheritance is also a feature of classes.
Bonus Day 4 will illustrate inheritance in more detail. - A private data member can only be accessed from other data members within a
class. - A public data member can be accessed directly from any part when the object is in
scope. - A constructor is executed when an object is instantiated.
- A destructor is executed when an object is destroyed.
- A class isn’t different from using other types of data as a data member. You can use
a class just as you can use an integer, character, structure, or any other data type. - a. base class
b. subclass
c. neither the base class nor the subclass
Theguppyis the subclass. - a. base class
b. subclass
c. neither the base class nor the subclass
Thefishis the base class.
13.class guppy : public fish { - The base class constructor executes first.
- The subclass destructor executes first.
876 Appendix F
49 448201x-APP F 8/13/02 11:22 AM Page 876