1. you should write down explanation for every line of the code. 2. you should e
ID: 3575026 • Letter: 1
Question
1. you should write down explanation for every line of the code.
2. you should explain about the example code. explanation for following contents should be included in this part.
- the inheritance structure of the Employee class
- mechanism of polymorphism in Employee class (explain with handle and virtual function)
- definition of dynamic binding and static binding
- the implementation mechanism and effect of polymorphism using vector
BasePlusCommissionEmployee E Ta h) 1 Fig. 13.21: Base PluscommissionEmployee.h 2 Base Pluscomm issionEmployee class derived from Employee 3 #ifndef BASE PLUS H 4 #define BASEPLUS H 6 #include "CommissionEmployee.h" Commi ssionEmployee class definition BasePlusCommissionEmpl 8 class Base Plus ission Employee public commissionEmployee oyee inherits from 9 Commission Employee, 10 public 11 BasePluscommissionEmployee C const string &, const string &, already concrete const string &, double 0.0, double 0.0, double 0.0 12 13 14 void setBasesalaryC double set base salary 15 double getBasesalaryO Const return base salary 16 17 keyword virtual signals intent to override 18 virtual double earnings O const; calculate earnings 19 virtual void print O Const pri Base Plus ission Employee object 20 private 21 double basesalary; base salary per wee Functions will be overidden 22 h; end class ssionEmployee 23 24 #endif BASEPLUS HExplanation / Answer
BasePlusCommisionEmployee.h
Line 3 and 4 definez the macros for the source code
Line number 6 include the header file named CommissionEmployee.h
Line number 8 define a class named BasePlusCommisionEmployee which inherit the class CommisionEmployee using Single inheritence.
Line 11 to 13 contain the defination of constructor which takes two paramaters as input and also initialize the data memebers with legal initial value.
Line 14 and 15 define a method to set the base salary
Line 18 and 19 define two methods of virtual type to calculate the earning and to print anything with virtual as base
BasePlusCommisionEmployee.cpp
This class give the definitaion of the constructor which is declared in the header file.
It also define the setSalary method which is declared in the header file.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.