warning C4553: '=='
bunenej (15)
Oct 30, 2012 at 4:11pm UTC
MyLife Me;
index == myList.searchList(Me);
confused on whats wrong ? :/
Moschops (5961)
Oct 30, 2012 at 4:13pm UTC
Is that meant to be index = myList.searchList(Me); ?
Last edited on Oct 30, 2012 at 4:16pm UTC
bunenej (15)
Oct 30, 2012 at 4:16pm UTC
error C2678: binary '==' : no operator found which takes a left-hand operand of type 'MyLife' (or there is no acceptable conversion)
error C2678: binary '==' : no operator found which takes a left-hand operand of type 'Parent' (or there is no acceptable conversion)
and what does this two mean ? :/
chipp (506)
Oct 30, 2012 at 4:16pm UTC
confused on whats wrong ?
maybe you just don't know what's == means
bunenej (15)
Oct 30, 2012 at 4:18pm UTC
if (*(mLife->nInfo) == searchkey) --> error for this :/
bunenej (15)
Oct 30, 2012 at 4:19pm UTC
it means to check if index is the equal to myList.searchList(Me); ?
bunenej (15)
Oct 30, 2012 at 4:20pm UTC
chipp does it mean that is checks if index equals myList.searchList(Me) ?
Moschops (5961)
Oct 30, 2012 at 4:23pm UTC
You are testing to see if index has the same value as myList.searchList(Me) . The compiler has no idea how to compare these two things because you have not written the == operator to compare them.
Is this what you meant to do?
Last edited on Oct 30, 2012 at 4:24pm UTC
bunenej (15)
Oct 30, 2012 at 4:26pm UTC
oh yes...thats what i want it to do...thanks...and can you help with the two other errors please...
chipp (506)
Oct 30, 2012 at 4:36pm UTC
try:
if (mLife->nInfo == searchkey)
does it mean that is checks if index equals myList.searchList(Me) ?
yes, but it doesn't do anything if index is equal to myList.searchList(Me)
btw, we can't give you the right answer if you don't post your full code (at least the one that related to your error)
Last edited on Oct 30, 2012 at 4:47pm UTC
Moschops (5961)
Oct 30, 2012 at 4:44pm UTC
What kind of object is index , and what kind of object is myList.searchList(Me) ? What does it even mean for them to be equal? I don't think you've thought about what you want to do enough.
bunenej (15)
Oct 30, 2012 at 4:46pm UTC
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
void Family::removeChoice()
{
Choice chc;
int index;
cout << "\nDetails of Person Removed" ;
cout << "\nID: " ;
cin >> chc.ID;
cout << "\nTYPE(Parent(p)/Child(c): " ;
cin >> chc.Type;
if (chc.Type = "p" )
{
Parent prnt;
index = parentList.searchList(prnt);
if (index==-1)
cout << "Cannot find person!" <<endl;
else
{
parentList.removeNode(index);
numPersons--;
}
}
else if (type == 'c' )
{
Child Chd;
index = childList.searchList(Chd);
if (index==-1)
cout << "Cannot find Person!" << endl;
else
{
childList.removeNode(index);
numPersons--;
}
}
else
cout << "Invalid Person Type!" <<endl;
}
bunenej (15)
Oct 30, 2012 at 4:47pm UTC
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
int List<Type>::searchList(Type searchkey)
{
int location = 0;
int notfound = -1;
for (Node<Type> *pNode = pHead; pNode != NULL; pNode = pNode->pNext)
{
if (*(pNode->nData) == searchkey)
return location; //found item at this location
else
location++;
}
return notfound; //item not in the list
}
chipp (506)
Oct 30, 2012 at 5:40pm UTC
it should be:
if (chc.Type == 'p' ) //if Type is char
and what searchList() does return?
bunenej (15)
Oct 31, 2012 at 2:58am UTC
searchList is suppose to return the place(index) where it finds the chc.ID
chipp (506)
Nov 3, 2012 at 6:45am UTC
and what type of it? is it an int ?