Chapter 12: Object-Oriented Programming: Inheritance
- a ComissionEmployee class which represents an employee who is paid
a percentage of gross sales
- Creating a BasePlusCommisionEmployee Class Without Using
Inheritance
- Creating a BasePlusCommissionEmployee Class Inherited from
CommissionEmployee
- ComissionEmployee-BasePlusCommissionEmployee Inheritance Hierarchy
Using protected Data
- However, the author suggests , from Software Engineering
Observation, to declare private data and access them via the
class's set and get member functions.
- BasePlusCommissionEmployee.h
is the same as the above.
- BasePlusCommissionEmployee.cpp
accesses the private data members of the base class via set and
get member functions.
- On P.557 L.35, when the derived class needs to invoke a
based-class member function (which has been redefined in the
derived class), the syntax is to place the base-class name and
the scope resoltuion operator (::) before the base-class
member-function name.
- CommissionEmployee.h is
the same as 1.
- In CommissionEmployee.cpp,
earnings() and print() also access its own private data members via
those get and set member functions, although this is not necessary.
- the same main program
as the above one.
- 12.5 Constructors and Destrucotrs in Derived Classes