• Shuffle
    Toggle On
    Toggle Off
  • Alphabetize
    Toggle On
    Toggle Off
  • Front First
    Toggle On
    Toggle Off
  • Both Sides
    Toggle On
    Toggle Off
  • Read
    Toggle On
    Toggle Off
Reading...
Front

Card Range To Study

through

image

Play button

image

Play button

image

Progress

1/8

Click to flip

Use LEFT and RIGHT arrow keys to navigate between flashcards;

Use UP and DOWN arrow keys to flip the card;

H to show hint;

A reads text to speech;

8 Cards in this Set

  • Front
  • Back
1. Explain the difference among the terms virtual function, late binding, and
polymorphism.
page missing in PDF?
2. Suppose you modify the definitions of the class Sale (Display 15.1) by deleting the
reserved word virtual. How would that change the output of the program in Display
15.5?
2. The output would change to the following:
Discounted item is not cheaper.
3. Is it legal to have an abstract class in which all member functions are pure virtual
functions?
3. Yes, it is legal to have an abstract class in which all member functions are pure virtual
functions.
4. Given the definition of the class Employee in Display 15.6, which of the following
are legal?
a.
Employee joe;
joe = Employee( );
b.
class HourlyEmployee : public Employee
{
public:
HourlyEmployee( );
<Some more legal member function definitions, none of which are pure virtual functions.>
private:
double wageRate;
double hours;
};
int main( )
{
Employee joe;
joe = HourlyEmployee( );
c.
bool isBossOf(const Employee& e1, const Employee& e2);
4. a. Illegal, because Employee is an abstract class.
b. Legal.
c. Legal, because an abstract class is a type.
5. Why can’t you assign a base class object to a derived class variable?
5. There would be no members to assign to the derived class’s added members.
6. What is the problem with the (legal) assignment of a derived class object to a base
class variable?
6. Although it is legal to assign a derived class object to a base class variable, this discards
the parts of the derived class object that are not members of the base class. This situation
is known as the slicing problem.
7. Suppose the base class and the derived class each has a member function with the
same signature. When you have a base class pointer to a derived class object and call a
function member through the pointer, discuss what determines which function is
actually called, the base class member function or the derived class member function.
7. If the base class function carries the virtual modifier, then the derived class member
function is called. If the base class member function does not have the virtual modifier,
then the base class member function is called.
page missing in PDF?
8. Since Dog can have more member variables than Pet, the object vpet may not have
enough data for all the member variables of type Dog.