Error: "Employee" is not a nonstatic data member or base class "employeessavitch::SalariedEmployee"

I'm getting the error that's the title of this thread. Here are my header files and implementation files thus far:

employee header file:
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
#ifndef TEST4_H
#define TEST4_H

#include <string>
using namespace std;

namespace employeessavitch
{

	class Employee
	{
	public:
		Employee();
		Employee(string the_name, string the_ssn);
		string get_name() const;
		string get_ssn() const;
		double get_net_pay() const;
		void set_name(string new_name);
		void set_ssn(string new_ssn);
		void set_net_pay(double new_net_pay);
		void print_check() const;
	protected:
		string name;
		string ssn;
		double net_pay;
	};
}


employee implementation file:
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
#endif

#include <string>
#include <cstdlib>
#include <iostream>
#include "test4.h"
using namespace std;

namespace employeessavitch
{
	Employee::Employee(): name("No name yet"), ssn("No number yet"), net_pay(0)
	{
	}

	Employee::Employee(string the_name, string the_number): name(the_name), ssn(the_number), net_pay(0)
	{
	}

	string Employee::get_name() const
	{
		return name;
	}

	string Employee::get_ssn() const
	{
		return ssn;
	}

	double Employee::get_net_pay() const
	{
		return net_pay;
	}

	void Employee::set_name(string new_name)
	{
		name = new_name;
	}

	void Employee::set_ssn(string new_ssn)
	{
		ssn = new_ssn;
	}

	void Employee::set_net_pay (double new_net_pay)
	{
		net_pay = new_net_pay;
	}

	void Employee::print_check() const
	{
		cout << "\nERROR: print_check FUNCTION CALLED FOR AN\n"
			 << "UNDIFFERENTIATED EMPLOYEE. Aborting the program.\n";
		exit(1);
	}
}


Salaried employee header file:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#ifndef SALARIEDEMPLOYEE_H
#define SALARIEDEMPLOYEE_H

#include <string>
#include "employee.h"

using namespace std;

namespace employeessavitch
{
	class SalariedEmployee : public Employee
	{
	public:
		SalariedEmployee();
		SalariedEmployee(string the_name, string the_ssn, double the_weekly_salary);
		double get_salary() const;
		void set_salary(double new_salary);
		void print_check();
	private:
		double salary;
	};
}

#endif 


Salaried Employee implementation file:
1
2
3
4
5
6
7
8
9
10
11
12
13
#include <iostream>
#include <string>
#include "SalariedEmployee.h"

using namespace std;

namespace employeessavitch
{
	SalariedEmployee::SalariedEmployee() : Employee(), salary(0)
	{

	}
}


The error corresponds to line 9 in the last file. Employee() appears underlined by a squiggly red line in MS visual. I'm guessing the problem has something to do with the fact that SalariedEmployee is derives from Employee but I can't pinpoint the error. I tired making the Employee() constructor protected in the first file but that didn't do anything. Sorry if this is an easy question but I'm just beginning learning about derived classes. Thank you for your effort in identifying the problem.
bump
Your employee implementation file includes "test4.h" yet SalariedEmployee.h includes "employee.h". Perhaps the error could be caused by that. Also, you shouldn't use using namespace ... globally within a header file.
Last edited on
Topic archived. No new replies allowed.