Question: C++ ; main.cpp is demonstrating inheritance as well as use of constructor and destructor. This keeps giving me a link error please fix it and

C++ ; main.cpp is demonstrating inheritance as well as use of constructor and destructor. This keeps giving me a link error please fix it and complete the program. main.cpp #include #include #include "BasePlusCommissionEmployee.h" // class definition using namespace std; int main() { // instantiate BasePlusCommissionEmployee object BasePlusCommissionEmployee employee( "Bob", "Lewis", "333-33-3333", 5000, .04, 300 ); // set floating-point output formatting cout << fixed << setprecision( 2 ); // get commission employee data cout << "Employee information obtained by get functions: " << " First name is " << employee.getFirstName() << " Last name is " << employee.getLastName() << " Social security number is " << employee.getSocialSecurityNumber() << " Gross sales is " << employee.getGrossSales() << " Commission rate is " << employee.getCommissionRate() << " Base salary is " << employee.getBaseSalary() << endl;*/ employee.setBaseSalary( 1000 ); // set base salary cout << " Updated employee information output by print function: " << endl; employee.print(); // display the new employee information // display the employee's earnings cout << " Employee's earnings: $" << employee.earnings() << endl; } // end main // TODO - Add an object of CommissionEmployee // Run the print method of CommissionEmployee ------------------------------------------------------------------ BasePlusCommissionEmployee.h #ifndef BASEPLUS_H #define BASEPLUS_H #include // C++ standard string class #include "CommissionEmployee.h" // CommissionEmployee class declaration class BasePlusCommissionEmployee : public CommissionEmployee { public: BasePlusCommissionEmployee( const std::string &, const std::string &, const std::string &, double = 0.0, double = 0.0, double = 0.0 ); void setBaseSalary( double ); // set base salary double getBaseSalary() const; // return base salary double earnings() const; // calculate earnings void print() const; // print BasePlusCommissionEmployee object private: double baseSalary; // base salary }; // end class BasePlusCommissionEmployee #endif ---------------------------------------------------------------- BasePlusCommissionEmployee.cpp // Fig. 11.11: BasePlusCommissionEmployee.cpp // Class BasePlusCommissionEmployee member-function definitions. #include #include #include "BasePlusCommissionEmployee.h" // class definition using namespace std; // constructor BasePlusCommissionEmployee::BasePlusCommissionEmployee( const string &first, const string &last, const string &ssn, double sales, double rate, double salary ) // explicitly call base-class constructor : CommissionEmployee( first, last, ssn, sales, rate ) { setBaseSalary( salary ); // validate and store base salary } // end BasePlusCommissionEmployee constructor // set base salary void BasePlusCommissionEmployee::setBaseSalary( double salary ) { if ( salary >= 0.0 ) baseSalary = salary; else throw invalid_argument( "Salary must be >= 0.0" ); } // end function setBaseSalary // return base salary double BasePlusCommissionEmployee::getBaseSalary() const { return baseSalary; } // end function getBaseSalary // calculate earnings double BasePlusCommissionEmployee::earnings() const { // derived class cannot access the base class's private data return baseSalary + ( commissionRate * grossSales ); } // end function earnings // print BasePlusCommissionEmployee object void BasePlusCommissionEmployee::print() const { // derived class cannot access the base class's private data cout << "base-salaried commission employee: " << firstName << ' ' << lastName << " social security number: " << socialSecurityNumber << " gross sales: " << grossSales << " commission rate: " << commissionRate << " base salary: " << baseSalary; } // end function print double earnings() const; // calculate earnings void print() const; // print BasePlusCommissionEmployee object private: double baseSalary; // base salary }; // end class BasePlusCommissionEmployee #endif --------------------------------------------------------------- ComissionEmployee.h #ifndef COMMISSION_H #define COMMISSION_H #include // C++ standard string class class CommissionEmployee { public: CommissionEmployee( const std::string &, const std::string &, const std::string &, double = 0.0, double = 0.0 ); void setFirstName( const std::string & ); // set first name std::string getFirstName() const; // return first name void setLastName( const std::string & ); // set last name std::string getLastName() const; // return last name void setSocialSecurityNumber( const std::string & ); // set SSN std::string getSocialSecurityNumber() const; // return SSN void setGrossSales( double ); // set gross sales amount double getGrossSales() const; // return gross sales amount void setCommissionRate( double ); // set commission rate (percentage) double getCommissionRate() const; // return commission rate double earnings() const; // calculate earnings void print() const; // print CommissionEmployee object protected: std::string firstName; std::string lastName; std::string socialSecurityNumber; double grossSales; // gross weekly sales double commissionRate; // commission percentage }; // end class CommissionEmployee #endif

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!