I added a new c++ file for my class but it isn't being recognized by inline methods in the .h file (Using Visual Studio)

I have a class called ProductionWorker that inherits from the Employee class. ProductionWorker started out as just a .h file with inline methods but now I have added a .cpp file called ProductionWorker.cpp by right clicking Source Files and doing Add..->New Item

I added these functions to the the .cpp file and commented them out of the header file. They worked fine when they were in the .h file but now I getting lots of these errors

1
2
3
1>...exception_project\productionworker.h(50): error C3861: 'checkPayRate': identifier not found
1>
...exception_project\productionworker.h(51): error C3861: 'checkShift': identifier not found



Also getting stuff like this

productionworker.cpp(15): error C2039: 'checkPayRate' : is not a member of 'ProductionWorker'


The highlighting in the .cpp file is weird too.

For this, only void and Worker is highlighted in blue. The rest is black

void ProductionWorker::checkShift()

And for this, only void and rker is highlighted in blue. The rest is black
void ProductionWorker::checkPayRate()



This is the contents of ProductionWorker.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include "Employee.h"
#include "ProductionWorker.h"

//validates the shift member
	void ProductionWorker::checkShift()
	{
		//shift can only be 1 for day shift or 2 for night shift
		if (shift < 1 || shift > 2) 
		{
			throw InvalidShift();
		}
	}

	//validates the payRate member
	void ProductionWorker::checkPayRate()
	{
		if (payRate < 0)
		{
			throw InvalidPayrate();
		}
	}



Solved... I forgot to uncomment the function headers in the .h file and put a semicolon after them lol
Last edited on
Topic archived. No new replies allowed.