error C2678

EDIT: DELETED
Last edited on
You're trying to compare a pointer from the iterator class to an unsigned int variable. What I'm thinking you want is to compare the iLoc value itself to the itemInput, because writing *iLoc == itemInput means you're trying to compare a memory location to an unsigned int variable.

EDIT: Disregard. I focused on line 203 and wasn't paying attention to the list type.
Last edited on
@ZeryouzLi:

You're trying to compare an unsigned int to an Employee object. Unless you have an overloaded == operator that handles that, it doesn't make any sense. Did you really mean to compare itemInput to one of the data members of Employee?

@YFGHNG:

No, that is not what *iLoc == itemInput means. *iLoc is "dereferencing" the iterator, i.e. it evaluates to an object of type Employee.
Yes I am. Am i suppose to override the it with this function?

1
2
3
4
5
bool Employee::operator==(const Employee & rhs) const
{

	return (this->Name == rhs.Name) && (this->ID == rhs.ID) && (this->Salary == rhs.Salary);
}
Last edited on
Without seeing the Employee class, commenting is difficult. However, there are some bread crumbs here that lead us to some educated guesses.

First of all, I'm not sure what itemInput is supposed to be. You declared it as an unsigned int, so that looks like an Employee ID number of some sort. However, you try to print it out as a name in line 16. However, you print it out as an ID# in line 23, so i guess line 16 is a mistake.

So, assuming itemInput is an ID number, the Employee class should have a function like getId() [your function name may vary] that returns the object's ID number. What you want to do is compare the ID number of each employee with the itemInput value. Line 14 would become

if (iLoc->getId() == itemInput)

If you want to use the comparison operation you posted just above, then you need an Employee object to compare against, not just an ID number.
I added the employee class, and the main.cpp i'm working on ATM.

basically, the user's input and ID of an employee and the program returns the employee information if it has it.
Why did you delete your post? You've basically destroyed any possibility that this thread could be a help or a learning resource for anyone else. It's incredibly selfish - you've gotten what you wanted, and now you're destroying any contribution this thread made to the site.
Topic archived. No new replies allowed.