Well, more code is necessary to tell for sure, particularly class and variable definitions, but I can give some suggestions. I am assuming here that your operator== is an inline-defined class member and employee is an array of Employee pointers.
First, the parameter(s) to an overloaded operator function like == that doesn't modify anything should be const references if they aren't basic types.
Second, the type that you get back from the expression *employee[j] is Employee. So operator== needs to be defined in the Employee class. If you have it defined in the subclasses and not the base class, not only is it a fundamental design problem because any operations that are the same in all subclasses should be in the base class, but also it simply won't work as the compiler spits out an ugly error. *edit*Actually I take back what I said before here if anyone read it. If you must have different implementations of operator== in each subclass, you can simply make it virtual. But it does still need to be defined in the base class and for such a simple operation you could probably just move the whole thing to the base class easily.
Also, this is just a stylistic issue, but you can simplify that implementation down to:
bool operator==(const string & lName)
{
return empLastName==lName;
}
Last edited by n0nsensical; 02-07-2005 at 04:10 PM..
|