I would think making it a friend function would be unnecessary. Seems like a virtual member function might work. Alternatively, make an accessor function for the employee number (rather than accessing the variable directly). I would imagine:
class Employee
{
public:
virtual bool operator==(const Employee &rhs)
{
return rhs.empNum == empNum;
}
// everything else
};
I didn't try compiling/running this code, so it may have bugs (or be outright wrong)! But it seems like this would be the better way to do it. In general, using friend is rarely the right way to do things.
__________________
"You're only given a little spark of madness. You mustn't lose it."
- Robin Williams
Last edited by ergdork; 02-13-2005 at 06:06 PM..
|