View Single Post
Old 02-07-2005, 10:14 AM   #1 (permalink)
Lebell
Cracking the Whip
 
Lebell's Avatar
 
Location: Sexymama's arms...
[c++] Operator overloading - call problem

I'm finishing up an assignment and I've hit a snag on calling an overloaded operator in a class.

Here's the generals,

-4 employee child classes created from a virtual "Employee Class"
-objects created dynamically and stored in a base pointer array
-each child class has an overloaded operator == in order to do a search by last name w/o using a get function.

The code for the overloaded operator looks like this:

-----------------------------------------------------

bool operator == (string lName)
{ bool result=false;
if (empLastName == lName)
result = true;
else
result=false;
return result;

}
-----------------------------------------------------

The compile error happens at the call:

-----------------------------------------------------

do
{
if (*employee[j] == findLastName)
{
found = true;
foundCount = j;
};
j++;
}while ((!found)&& j<empCount);

----------------------------------------------------

The error is funky:

error C2784: 'bool std:perator ==(const std::basic_string<_Elem,_Traits,_Alloc> &,const _Elem *)' : could not deduce template argument for 'const std::basic_string<_Elem,_Traits,_Ax> &' from 'Employee'

----------------------------------------------------

Anyway, any ideas would be greatly appreciated
__________________
"Of all tyrannies, a tyranny exercised for the good of its victims may be the most oppressive. It may be better to live under robber barons than under omnipotent moral busybodies. The robber baron's cruelty may sometimes sleep, his cupidity may at some point be satiated; but those who torment us for our own good will torment us without end, for they do so with the approval of their own conscience." – C. S. Lewis

The ONLY sponsors we have are YOU!

Please Donate!
Lebell is offline  
 

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60