Class functions

Doing a project for an intermediate C++ class in Qt and I've run into a little problem that I can't figure out. I'm sure the solution is simple but my head doesn't want to cooperate.
We had to create three classes (employer, person, and position) then use them in main to make a simple hiring program. We had to follow a UML guide so I can't really change the function signatures.
I got rid of most errors but the last ones I have are with the hire function in the employer class.

c2027: use of undefined type 'Person'
c2228: left of '.setPosition' must have class/struct/union

1
2
3
4
5
6
bool Employer::hire(Person& newHire, Position pos)
{
    Employer company = Employer(m_Name, m_market);
    newHire.setPosition(company, pos);
    return 1;
}


I'm not sure what it wants from me.
setPosition isn't a complicated thing either.

1
2
3
4
5
6
void Person::setPosition(Employer newC, Position newP)
{
    m_position = newP;
    m_employer = newC;
    m_Employed = 1;
}
c2027: use of undefined type 'Person'

That is the error.

The translation unit at the point of Emplyer::hire() has not seen the definition of "Person".
Where do you have the:
1
2
3
class Person {
  // declarations
};
I figured it out, probably.
Including the Person class at the top broke everything, but placing it right before the function worked...
Topic archived. No new replies allowed.