Question: 11.3 (Composition as an Alternative to Inheritance) Many programs written with inheritance can be written with composition instead, and vice versa. Rewrite class BasePlusCommissionEmployee of

 11.3 (Composition as an Alternative to Inheritance) Many programs written withinheritance can be written with composition instead, and vice versa. Rewrite classBasePlusCommissionEmployee of the CommissionEmployee-BasePlusCommissionEmployee hierarchy to use composition rather than inheritance. Afteryou do this, assess the relative merits of the two approaches for

11.3 (Composition as an Alternative to Inheritance) Many programs written with inheritance can be written with composition instead, and vice versa. Rewrite class BasePlusCommissionEmployee of the CommissionEmployee-BasePlusCommissionEmployee hierarchy to use composition rather than inheritance. After you do this, assess the relative merits of the two approaches for designing classes CommissionEmployee and BasePlusCommissionEmployee, as well as for object-oriented pro- grams in general. Which approach is more natural? Why? I /Fig. 11.14: CommissionEmployee.cpp 2 II Class CommissionEmployee member-function definitions #incl ude #include #include 5 = 1.0) { 58 59 60 throw invalid argument(" Commission rate must be0.0 and1.0 commissionRate -rate: 62 63 64 IIreturn commission rate 65 double CommissionEmployee::getCommissionRateO const return commissionRate; 67 68 69 calculate earnings 70 double CommissionEmployee::earningsO const return getCommissionRateOgetGrossSales O 72 73 74 I/ return string representation of CommissionEmployee object 5 string CommissionEmployee: :toStringO const 76 77 output

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!