Extra qualification on member 'Operator>'

I keep getting the error extra qualification on member 'Operator>' and I don't understand why. The error is with the statements below. I also tried changing it so that it just reads Employee2 operator>(Employee2& emp) but then it says it must have exactly 2 variables. Any help on this would be greatly appreciated.

bool Employee2::operator>(Employee2& emp); //in my header file

bool Employee2::operator>(Employee2& emp) //in my Employee2.cpp file
{
if(this->GetTotalEarned() > emp.GetTotalEarned())
{
cout << "The first Employee2 has earned more" << endl;
};
if(emp.GetTotalEarned() > this->GetTotalEarned())
{
cout << "The second Employee2 has earned more" << endl;
};
if(emp.GetTotalEarned() == this->GetTotalEarned())
{
cout << "Both Employee2's have earned the same amount" << endl;
}
return false;
}
Last edited on
please post the whole code or tell us where in your header you defined that operator.
and use codetags "<>"
sorry for the confusion, I'm still a little new to the forum but below is the full header code, most isn't important to know but the
bool Employee2::operator>(Employee2& emp); that is giving me errors in in public.

#ifndef Employee2_H //Employee2_H
#define Employee2_H
#include <string>

using namespace std;
class Employee2
{
public:
Employee2( unsigned int newID, string newLastName, string newFirstName, float newHourlyRate);
int GetID();
friend ostream& operator<<(ostream& stream, Employee2& cn );
void operator++();
void operator++(int dummy);
bool Employee2::operator>(Employee2& emp);
void SetID(int n);
string GetFirstName();
void SetFirstName(string str);
string GetLastName();
void SetLastName(string str);
float GetHourlyRate();
void SetHourlyRate(float n);
float Pay(float nHours);
float SalaryEarned( float nHours);
float GetTotalEarned();

private:
unsigned int ID;
string LastName;
string FirstName;
float HourlyRate;
float TotalEarned;
void increment();
};

#endif //Employee2_H
Remove Employee2:: in front of the the operator
I removed that but then it reads back an error that the operator> must take exactly two arguments, which mine only has one
Then put two arguments in.
I removed that but then it reads back an error that the operator> must take exactly two arguments, which mine only has one
in your header file within your class of course. Why is that so difficult to see?
Topic archived. No new replies allowed.