Please help guys :)

Hey everyone, I'm new to C++, and keep getting stuck with this in Inheritance.

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
#include <iostream>
#include <string>

class Employee
{
	protected:
		std::string empID;
		std::string empName;
		std::string response;
		float grossPay;

	private:
		int hoursWorked;
		float hourlyRate;

	public:
		Employee()
		{
			empID = "";
			empName = "";
			hoursWorked = 0;
			hourlyRate = 0;
			grossPay = 0;
		}

	protected:
		void SetEmpID()
		{
			empID = "123451223";
		}
		void SetEmpName()
		{
			std::cout << "\nEnter employee name?  ";
			std::getline(std::cin, response);
			while (response.length() == 0)
			{
				std::cout << "\nEnter employee name?  ";
				std::getline(std::cin, response);
			}
			empName = response;
		}
		void SetHoursWorked()
		{
			std::cout << "\nEnter Amount of Hours Worked:  ";
			std::getline(std::cin, response);
			hoursWorked = stoi(response);
		}
		void SetHourlyRate()
		{
			std::cout << "\nEnter Hourly Rate:  ";
			std::getline(std::cin, response);
			hourlyRate = stof(response);
		}

	public:
		virtual void Calculate()
		{
			SetEmpID();
			SetEmpName();
			SetHoursWorked();
			SetHourlyRate();
			grossPay = hoursWorked * hourlyRate;
		}
		float GetGrossPay()
		{
			return grossPay;
		}
		virtual void Display()
		{
			std::cout << "\n\n**  Employee Info  **";
			std::cout << "\nEmployee ID:  " << empID;
			std::cout << "\nEmployee Name:  " << empName;
			std::cout << "\nHours Worked:  " << hoursWorked;
			std::cout << "\nHourly Rate:  " << hourlyRate;
			std::cout << "\n\nGross Pay:  " << GetGrossPay();
		}
};

#include <iostream>
#include <string>
#include "Employee.cpp"

class SalariedEmployee : public Employee
{
	private:
		float annualSalary;

	public:
		SalariedEmployee()
		{
			annualSalary = 0;
		}

	protected:
		void SetAnnualSalary()
		{
			std::cout << "\nEnter Annual Salary:  ";
			std::getline(std::cin, response);
			while (response.length() == 0)
			{
				std::cout << "\nEnter Annual Salary:  ";
				std::getline(std::cin, response);
			}
			annualSalary = stof(response);
		}

	public:
		virtual void Calculate()
		{
			SetAnnualSalary();
			grossPay = annualSalary / 26;
		}
		virtual void Display()
		{
			std::cout << "\n\n** Salaried Employee Details  **";
			std::cout << "\nEmployee ID:  " << empID;
			std::cout << "\nEmployee Name:  " << empName;
			std::cout << "\nAnnual Salary:  " << annualSalary;
			std::cout << "\n\nGross Pay:  " << GetGrossPay();
		}
};

#include <iostream>
#include <string>
#include "Employee.cpp"
#include "SalariedEmployee.cpp"

int main()
{
	Employee employee1;
	SalariedEmployee employee2;
	std::cout << "\n\n";
	system("PAUSE");
	return 0;
}
I see no question here.
Yes my apologies, I'm getting so many errors it wont compile. My question is what is wrong with this code.
>c:\users\anton\documents\visual studio 2013\projects\inheritence\inheritence\employee.cpp(5): error C2011: 'Employee' : 'class' type redefinition
1> c:\users\anton\documents\visual studio 2013\projects\inheritence\inheritence\employee.cpp(5) : see declaration of 'Employee'
1>c:\users\anton\documents\visual studio 2013\projects\inheritence\inheritence\salariedemployee.cpp(6): error C2504: 'Employee' : base class undefined
1>c:\users\anton\documents\visual studio 2013\projects\inheritence\inheritence\salariedemployee.cpp(20): error C2065: 'response' : undeclared identifier
Get rid of #include "Employee.cpp" in your main file
O thank you Kevin, is it because it's been included in the derived class?
Yes. Typically cpp files are compiled separately then linked together. The way you are doing it also works though, but c++ does not like when programmers repeat themselves.
I found a tutorial for multiple files written with visual studio in mind:
http://www.learncpp.com/cpp-tutorial/18-programs-with-multiple-files/
Thx very much for your time and help Kevin.
Topic archived. No new replies allowed.