warning C4553: '=='

MyLife Me;
index == myList.searchList(Me);

confused on whats wrong ? :/
Is that meant to be index = myList.searchList(Me);?
Last edited on
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 ? :/
confused on whats wrong ?

maybe you just don't know what's == means
if (*(mLife->nInfo) == searchkey) --> error for this :/
it means to check if index is the equal to myList.searchList(Me); ?
chipp does it mean that is checks if index equals myList.searchList(Me) ?
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
oh yes...thats what i want it to do...thanks...and can you help with the two other errors please...
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
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.
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;

}
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
}
 
if (chc.Type = "p")

it should be:

 
if (chc.Type == 'p') //if Type is char 


and what searchList() does return?
searchList is suppose to return the place(index) where it finds the chc.ID
and what type of it? is it an int?
Topic archived. No new replies allowed.