Help and Feedback

I have been working on this all day and can not figure out why my overloaded setAnnualSalary functions are not working. Can anyone point me in the right direction? Employee 1 is fine, Employee 2(Salaried) does not compute the salary with the bonus (annual salary of 50K should be 1250 per week), and Employee 3 (Hourly) does not compute the annuals salay properly (40/hr * 50 hours should be 100K year and 2k a week). Would also like any feedback that you might have on how I am doing things. Thanks!!!

Main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
// Preprocessor Directives
#include "stdafx.h"
#include "Employee.h"
#include "Hourly.h"
#include "Salaried.h"
#include <iostream>
#include <string>
using namespace std;
//----------------------------------------------------------------------------------------------
// Main Function
int main()
{
	// Call DisplayApplicationInformation and DisplayDivider Proceedures
	DislayApplicationInformation();
	DisplayDivider("Employee 1");

	// Construct Employee1 Object and Benefit Object
	Employee employee1;  
	char gender;
	string tempString;
	Benefit benefit;

	// Getting Employee1 Data
	employee1.setFirstName(GetInput("First Name "));
	employee1.setLastName(GetInput("Last Name "));
	tempString = GetInput("Gender ");
	gender = tempString.at(0);
	employee1.setGender(gender);  
	employee1.setDependents(GetInput("Dependents "));
	employee1.setAnnualSalary(GetInput("Annual Salary "));
	employee1.setBenefit(benefit);

	// Calling DisplayDivider2 and DisplayEmployee Proceedures for Employee 1
	DisplayDivider2("Employee Information"); 
	employee1.displayEmployee();  
	cout << "\n--- Number of Employee Objects Created ----\t";
	cout << "Number of employees: " << Employee::getNumEmployees() << "\n"; 
	DisplayDivider("Employee 2");	

	// Construct Salaried Employee and Benefit2 Objects
	Benefit SalariedBenefit;
	Salaried employee2;
	int managementLevel;

	// Get Salaried Employee Data
	employee2.setFirstName(GetInput("First Name "));
	employee2.setLastName(GetInput("Last Name "));
	tempString = GetInput("Gender ");
	gender = tempString.at(0);
	employee2.setGender(gender);  
	employee2.setDependents(GetInput("Dependents "));
	employee2.setAnnualSalary(GetInput("Annual Salary "));
	tempString = GetInput("Management Level ");
	managementLevel = atoi(tempString.c_str());
	employee2.setManagementLevel(managementLevel);
	employee2.setBenefit(benefit);

	// Calling DisplayDivider, DisplayDivider2 and DisplayEmployee Proceedures for Employee 2
	DisplayDivider2("Employee Information");
	employee2.displayEmployee();
	cout << "\n--- Number of Employee Objects Created ----\t";
	cout << "Number of employees: " << Employee::getNumEmployees() << "\n"; 
	DisplayDivider("Employee 3");

	//Construct Hourly Employee and Benefit1 Objects
	Benefit hourlyBenefit;
	Hourly employee3;

	// Get Hourly Employee Data
	employee3.setFirstName(GetInput("First Name "));
	employee3.setLastName(GetInput("Last Name "));
	tempString = GetInput("Gender ");
	gender = tempString.at(0);
	employee3.setGender(gender);  
	employee3.setDependents(GetInput("Dependents "));
	employee3.setBenefit(benefit);
	employee3.setWage(atof(GetInput("Wage").c_str()));
	employee3.setHours(atof(GetInput("Hours").c_str()));
	employee3.setCategory(GetInput("Category"));
	employee3.setAnnualSalary();

	// Calling DisplayDivider, DisplayDivider2 and DisplayEmployee Proceedures for Employee 3
	DisplayDivider2("Employee Information");
	employee3.displayEmployee();
	cout << "\n--- Number of Employee Objects Created ----\t";
	cout << "Number of employees: " << Employee::getNumEmployees() << "\n"; 

	// Call TerminateApplication Proceedure
	TerminateApplication();

	return 0;
}
//----------------------------------------------------------------------------------------------
// DisplayApplicationInformation Procedure
void DislayApplicationInformation()
{
	// Display Program Header
	cout << "Welcome to your first Object Oriented Program\n";
	cout << "Employee Class CIS247C, Week 4 Lab\n";
	cout << "Name: Jim Stevens\n";
}
//----------------------------------------------------------------------------------------------
// DisplayDivider Prodedure
void DisplayDivider(string outputTitle)
{
	// Display Divider with Output Title
	cout << "************************" << outputTitle <<"************************\n";
}
//----------------------------------------------------------------------------------------------
// DisplayDivider2 Prodedure
void DisplayDivider2(string outputTitle)
{
	// Display Divider with Output Title
	cout << "\n" << outputTitle << endl;
	cout << "----------------------------------------------------------------\n";
}
//----------------------------------------------------------------------------------------------
// GetInput Function
string GetInput (string inputType)
{ 
	// Declare Function Varaible
	string input;
	// Prompt User for Input
	cout<<"Please enter your "<< inputType <<": ";
	getline(cin, input);
	return input;
}
//----------------------------------------------------------------------------------------------
// TerminateApplication Procedure
void TerminateApplication()
{
	// Display Termination Message
	cout << "\nThank you for using the Employee Class program\n";
}
//---------------------------------------------------------------------------------------------- 


Employee.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
// Preprocessor Directives
#pragma once
#include "Benefit.h"
#include <string>
using namespace std;
//---------------------------------------------------------------------------------------
// Declare Prototypes
void DislayApplicationInformation();
void DisplayDivider(string);
void DisplayDivider2(string);
string GetInput (string);
void TerminateApplication();
//---------------------------------------------------------------------------------------
/* Define iEmployee Class
class iEmployee
{
public:
virtual double calculatePay()= 0;
};*/
//---------------------------------------------------------------------------------------
// Define Employee Class
class Employee
{
protected:
	string firstName;
	string lastName;
	char gender;
	int dependents;
	double annualSalary;
	Benefit benefit;

public:
	// Constructors and Destructor
	Employee(void);
	Employee(string, string, char, int, double, Benefit);
	~Employee(void);

	// Methods to Access Attributes
	double calculatePay();
	void displayEmployee();

	// Getters and Setters
	string Employee::getFirstName();
	void Employee::setFirstName(string);
	void Employee::setLastName(string);
	string Employee::getLastName();
	char Employee::getGender();
	void Employee::setGender(char);
	int Employee::getDependents();
	void Employee::setDependents(int);
	void Employee::setDependents(string);  
	double Employee::getAnnualSalary();
	void virtual Employee::setAnnualSalary(double);
	void virtual Employee::setAnnualSalary(string);  
	Benefit Employee::getBenefit();
	void Employee::setBenefit(Benefit);
	static int getNumEmployees();

private:
	// Declare Data Members
	static int numEmployees;
};
//--------------------------------------------------------------------------------------- 
Employee.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
// Preprocessor Directives
#include "stdafx.h"
#include "Employee.h"
#include <iostream>
#include <iomanip>
//----------------------------------------------------------------------------------------------
// Declare Variables
const double minSalary = 50000;
const double maxSalary = 250000;
const int maxDepenents = 10;
const int minDependents = 0;
const char defaultGender= 'U';
const int numberOfWeeks = 52;
int Employee::numEmployees = 0;
//----------------------------------------------------------------------------------------------
// Default Employee Constructor
Employee::Employee() : firstName("not given"), lastName("not given"), gender('U'), dependents(0), annualSalary(20000.0)
{
	numEmployees++;
}
//----------------------------------------------------------------------------------------------
// Multi-Arg Employee Constructor
Employee::Employee(string first, string last, char gen, int dep, double salary, Benefit ben) :

	firstName(first),
	lastName(last),
	gender(gen),
	dependents(dep),
	annualSalary(salary),
	benefit(ben)
{
	numEmployees++;
}
//----------------------------------------------------------------------------------------------
// Employee Deconstructor
Employee::~Employee()
{
	numEmployees--;
}
//----------------------------------------------------------------------------------------------
// Define CalculatePay Function
double Employee::calculatePay()
{
	return (annualSalary/numberOfWeeks);
}
//----------------------------------------------------------------------------------------------
// DisplayEmployee Function
void Employee::displayEmployee()
{
	cout << "Employee Name:\t\t" << firstName << " " << lastName << "\n";
	cout << "Employee Gender:\t" << gender << "\n";
	cout << "Employee Dependents:\t" << dependents << "\n";
	cout << "Employee Annual Salary:\t$" << setprecision(2) << showpoint << fixed << annualSalary << "\n";
	cout << "Employee Weekly Pay:\t$" << setprecision(2) << showpoint << fixed << calculatePay() << "\n";
	benefit.displayBenefits();
}
//----------------------------------------------------------------------------------------------
// Define GetFirstName and SetFirstName
string Employee::getFirstName()
{
	return firstName;
}
void Employee::setFirstName(string name)
{
	firstName = name;
}

string Employee::getLastName()
{
	return lastName;
}
void Employee::setLastName(string name)
{
	lastName = name;
}
//----------------------------------------------------------------------------------------------
// Define GetGender and SetGender
char Employee::getGender()
{
	return gender;
}

void Employee::setGender(char gen)
{
	switch (gen)
	{
	case 'f':case 'F': case 'M':case 'm':
		gender = gen;
		break;
	default:
		gender = defaultGender;
	}
}
//----------------------------------------------------------------------------------------------
// Define GetDependents and both SetDependents (overloaded)
int Employee::getDependents()
{
	return dependents;
}

void Employee::setDependents(int dep)
{
	if (dep >= minDependents && dep <= maxDepenents)
	{
		dependents = dep;
	}
	else if (dep < minDependents)
	{
		dep = minDependents;
	}
	else
	{
		dependents = maxDepenents;
	}
}

void Employee::setDependents(string dep)
{
	Employee::setDependents(atoi(dep.c_str()));
}
//----------------------------------------------------------------------------------------------
// Define GetAnnualSalary and both SetAnnualSalary (overloaded)
double Employee::getAnnualSalary()
{
	return annualSalary;
}

void Employee::setAnnualSalary(double salary)
{
		annualSalary = salary;
}

void Employee::setAnnualSalary(string sal)
{
	Employee::setAnnualSalary( atof(sal.c_str())); 
}
//----------------------------------------------------------------------------------------------
// Define GetBenefit and SetBenefit
Benefit Employee::getBenefit()
{
	return benefit;
}

void Employee::setBenefit(Benefit)
{
	string tempString;
	double lifeInsurance;
	int vacation;
	benefit.setHealthInsurance(GetInput("Health Insurance "));
	tempString = GetInput("Life Insurance");
	lifeInsurance = atof(tempString.c_str());
	benefit.setLifeInsurance(lifeInsurance);
	tempString = GetInput("Vacation ");
	vacation = atoi(tempString.c_str());
	benefit.setVacation(vacation);
}
//----------------------------------------------------------------------------------------------
// Define GetNumEmployees
int Employee::getNumEmployees()
{
	return Employee::numEmployees; 
}
//---------------------------------------------------------------------------------------------- 


Benefit.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// Preprocessor Directives
#pragma once
#include <string>
using namespace std;
//----------------------------------------------------------------------------------------------
// Define Benefit Class
class Benefit
{
public:
	// Constructors and Destructor
	Benefit();
	Benefit(string, double, int);
	~Benefit();

	// Methods to Access Attributes
	void displayBenefits();

	// Getters and Setters
	string Benefit::getHealthInsurance();
	void Benefit::setHealthInsurance(string);
	double Benefit::getLifeInsurance();
	void Benefit::setLifeInsurance(double);
	int Benefit::getVacation();
	void Benefit::setVacation(int);

private:
	// Declare Data Members
	string healthInsurance;
	double lifeInsurance;
	int vacation;
};
//---------------------------------------------------------------------------------------------- 


Benefit.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
// Preprocessor Directives
#include "stdafx.h"
#include "Employee.h"
#include "Benefit.h"
#include <iostream>
#include <iomanip>
//----------------------------------------------------------------------------------------------
// Default Benefit Constructor
Benefit::Benefit() : healthInsurance("not provided"), lifeInsurance(0.0), vacation(14)
{	
}
//----------------------------------------------------------------------------------------------
// Multi-Arg Benefit Constructor
Benefit::Benefit(string health, double life, int vac) :
	healthInsurance(health),
	lifeInsurance(life),
	vacation(vac)
{
}
//----------------------------------------------------------------------------------------------
// Benefit Deconstructor
Benefit::~Benefit()
{
}
//----------------------------------------------------------------------------------------------
// DisplayBenefits Function  
void Benefit::displayBenefits()
{
	cout << "\nBenefit Information\n";
	cout << "----------------------------------------------------------------\n";
	cout << "Health Insurance: \t" << healthInsurance << "\n";
	cout << "Life Insurance: \t" << setprecision(2) << showpoint << lifeInsurance << "\n";
	cout << "Vacation: \t\t" << vacation << " days\n";
}
//----------------------------------------------------------------------------------------------
// Define GetHealthInsurance and SetHealthInsurance
string Benefit::getHealthInsurance()
{
	return healthInsurance;
}

void Benefit::setHealthInsurance(string newHealthInsurance)
{
	healthInsurance = newHealthInsurance;
}
//----------------------------------------------------------------------------------------------
// Define GetLifeInsurance and SetLifeInsurance
double Benefit::getLifeInsurance()
{
	return lifeInsurance;
}

void Benefit::setLifeInsurance(double newLifeInsurance)
{
	lifeInsurance = newLifeInsurance;
}
//----------------------------------------------------------------------------------------------
// Define GetVacation and SetVacation
int Benefit::getVacation()
{
	return vacation;
}

void Benefit::setVacation(int newVacation)
{
	vacation = newVacation;
}
//---------------------------------------------------------------------------------------------- 


Salaried.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// Preprocessor Directives
#pragma once
#include "employee.h"
//----------------------------------------------------------------------------------------------
// Defien Salaried Class
class Salaried :
	public Employee
{
public:
	// Constructors and Deconstructor
	Salaried();
	Salaried(string, string, char, int, double, Benefit, int);
	Salaried(double, int);
	~Salaried();

	// Methods to Access Attributes
	double calculatePay()
	{
		return Employee::calculatePay() * (1 + (managementLevel*bonusPercent));
	};
	void displayEmployee();

	//Getters and Setters
	int Salaried::getManagementLevel();
	void Salaried::setManagementLevel(int);

private:
	// Declare Data Members
	int minManagementLevel;
	int maxManagementLevel;
	double bonusPercent;
	int managementLevel;
};
//---------------------------------------------------------------------------------------------- 


Salaried.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
// Preprocessor Directives
#include "stdafx.h"
#include "Salaried.h"
#include "Employee.h"
#include <iostream>

using namespace std;
//----------------------------------------------------------------------------------------------
// Default Salaried Constructor
Salaried::Salaried() : Employee(), minManagementLevel(0), maxManagementLevel(3), bonusPercent(.10)
{	
	managementLevel = 0;
}
//----------------------------------------------------------------------------------------------
// Multi-Arg Salaried Constructor #1
Salaried::Salaried(string firstName, string lastName, char gender, int dependent, double salary, Benefit benefit, int managementLevel) : 
	Employee (firstName, lastName, gender, dependents, salary, benefit), minManagementLevel(0), maxManagementLevel(3), bonusPercent(.10)
{
}
//----------------------------------------------------------------------------------------------
// Multi-Arg Salaried Constructor #2
Salaried::Salaried(double salary, int managementLevel) : Employee(), minManagementLevel(0), maxManagementLevel(3), bonusPercent(.10)
{
}
//----------------------------------------------------------------------------------------------
// Default Salaried Deconstructor
Salaried::~Salaried()
{
}
//----------------------------------------------------------------------------------------------
/* CalculatePay Override Function
double Salaried::calculatePay()
{
return Employee::calculatePay() * (1 + (managementLevel*bonusPercent));
}*/
//----------------------------------------------------------------------------------------------
// DisplayEmployee Override Fumction
void Salaried::displayEmployee()
{
	Employee::displayEmployee();
	cout<<"Salaried Employee\n";
	cout<<"Management Level:\t" << managementLevel << "\n";
}
//----------------------------------------------------------------------------------------------
// GetManagement and SetManagement Functions
int Salaried::getManagementLevel()
{
	return managementLevel;
}

void Salaried::setManagementLevel(int manLevel)
{
	if (managementLevel >= 0 && managementLevel <= 3)
	{
		managementLevel = manLevel;
	}
	else
	{
		cout << "Invalid Input" << "\n";
	}
}
//---------------------------------------------------------------------------------------------- 


Hourly.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// Preprocessor Directives
#pragma once
#include "employee.h"
//----------------------------------------------------------------------------------------------
// Define Hourly Class
class Hourly :
	public Employee
{
public:
	// Constructors and Deconstructor
	Hourly();
	Hourly(double, double, string);
	Hourly(string, string, char, int, double, double, Benefit, string);
	~Hourly();

	// Methods to Access Attributes
	double calculatePay();
	void displayEmployee();

	// Getters and Setters
	void setAnnualSalary();
	double Hourly::getWage();
	void Hourly::setWage(double);
	double Hourly::getHours();
	void Hourly::setHours(double);
	string Hourly::getCategory();
	void Hourly::setCategory(string);

private:
	const double minWage;
	const double maxWage;
	const double minHours;
	const double maxHours;
	double wage;
	double hours;
	string category;	
};
//---------------------------------------------------------------------------------------------- 


Hourly.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
// Preprocessor Directives
#include "stdafx.h"
#include "Hourly.h"
#include <iostream>
//----------------------------------------------------------------------------------------------
// Default Hourly Constructor
Hourly::Hourly():Employee(), minWage(10), maxWage(75), minHours(0), maxHours(50)
{
	double wage = 0.0;
	double hours = 0.0;
	string category = "X";
}
//----------------------------------------------------------------------------------------------
// Multi-Arg Hourly Constructor #1
Hourly::Hourly(double wage, double hours, string category) : Employee(), minWage(10), maxWage(75), minHours(0), maxHours(50)
{
}
//----------------------------------------------------------------------------------------------
// Multi-Arg Hourly Constructor #2
Hourly::Hourly(string firstName, string lastName, char gender, int dependents, double wage, double hours, Benefit benefit, string category) :
	Employee(firstName, lastName, gender, dependents, 0.0, benefit), minWage(10), maxWage(75), minHours(0), maxHours(50)
{
}
//----------------------------------------------------------------------------------------------
// Default Hourly Deconstructor
Hourly::~Hourly()
{
}
//----------------------------------------------------------------------------------------------
// CalculatePay Override Function
double Hourly::calculatePay()
{
	return (wage * hours);
}
//----------------------------------------------------------------------------------------------
// Overloaded SetAnnualSalary
void Hourly::setAnnualSalary()
{
	return Employee::setAnnualSalary(calculatePay()*50);
}
//----------------------------------------------------------------------------------------------
// DisplayEmployee Override Function
void Hourly::displayEmployee(void)
{
	Employee::displayEmployee();
	cout<<"Hourly Employee\n";
	cout<<"Category:\t\t" << category << "\n";
	cout<<"Wage:\t\t\t" << wage << "\n";
	cout<<"Hours:\t\t\t" << hours << "\n";
}
//----------------------------------------------------------------------------------------------
// GetWage and SetWage Functions
double Hourly::getWage()
{
	return wage;
}
void Hourly::setWage(double Wage)
{
	wage = Wage;
}
//----------------------------------------------------------------------------------------------
//GetHours and SetHours Function
double Hourly::getHours()
{
	return hours;
}
void Hourly::setHours(double Hours)
{
	hours = Hours;
}
//----------------------------------------------------------------------------------------------
// GetCategory and SetCategory Functions
string Hourly::getCategory()
{
	return category;
}
void Hourly::setCategory(string cat)
{
	if(  category == "temporary" || category == "part time" || category == "full time" ) 
		category = cat;
	else
		category = "Unknown";
}
//---------------------------------------------------------------------------------------------- 
anyone?? This has to be something stupid that I am not seeing.
First, please learn to reduce your code to a minimal, compilable example that reproduces the problem you're experiencing. Nobody wants to wade through 7 files worth of code because you were too lazy to cut it down to a reasonable amount. For instance:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include <string>

class Base
{
public:

    virtual void setAnnualSalary(double);
    virtual void setAnnualSalary(const std::string &);
};

class Derived : public Base
{
public:

    void setAnnualSalary() ;
};

int main()
{
    Derived d ;
    d.setAnnualSalary("50000.00") ;
}


That is enough to illustrate your problem.

You'll notice that the Derived declaration of setAnnualSalary differs from both of the overloaded functions of the same name in Base. This hides the Base class functions of the same name. The correct way to override virtual functions, is to do so with the same signature so that you are actually overriding the functions instead of adding another overload.

In your case, you shouldn't even be adding an implementation to the derived classes, since the base class implementation does the correct thing.
Cire, I do appreciate the help. Believe me; I am not being lazy, just still learning how things are done. Was not sure where the issue was so I was hesitant to leave anything out. It is just as laborious for me to paste it all as it is for you to wade thru it all. We have not gone over virtual functions yet, according to this week’s lecture that is next week along with pointers. I don't even remember putting the virtual keywords in there. Yuo say that I sould not be adding an immplmentation to the derived clas, however the psudeocode we are going by specificly says to do just that. It is also in the UML diagram. Mistake or are they still teaching some bad habits?? I seem to have picked up a few that have had to be corrected. Again, thanks for the help!
Last edited on
If the base class implementation does the correct thing, the only thing you gain by adding another implementation in the derived class is an opportunity to make mistakes.

If you don't provide a derived class implementation, you're basically telling it to use the base class implementation, which is to say you are providing an implementation, just not explicitly, although I suppose you could make it explicit with a using directive:

1
2
3
4
5
6
class Derived : public Base
{
public:

    using Base::setAnnualSalary ;
};
Topic archived. No new replies allowed.