Am I misusing the operator< & operator== overloads?

I have a program that has a set of items that you can add and delete from including a const iterator, pair and of course set.

one of my switch cases for the main program is to locate an item and the other is to delete, but both use the same .find(item) function and compare the iterator to .end() to determine if it was located

the first part of my main code is
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
61
62
63
64
65
66
#include<iostream>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include <set>
#include <iterator>
#include "Item.h"


using namespace std;

//Function prototypes
...
//end function prototypes

int main()
{
	const int MAX = 10;
	set<Item> itemList;
	set<Item>::const_iterator loc;
	pair<set<Item>::const_iterator,bool> pairSet;
	int menuOption;
	Item item;
	programIntro();
	bool menuDisplayed=false;
	char* model;
	
	//do while loop for menu option
		switch(menuOption)
		{
			case 1: //enter information for an item
...

			case 2://delete a item
				if(itemList.empty())
				{
					cout << "List is Empty" << endl;
				}else{
					Item toDelete = getModelKey("Please Enter an item model to delete: ");
					loc = itemList.find(toDelete);
					if(loc!=itemList.end()){
						itemList.erase(*loc);

						cout<<"The "<<toDelete.getModel()<<
							" was successfully deleted"<<endl;
					}else{
						cout<< "There are no "<<toDelete.getModel()<<"'s in the list"<<endl;
					}
				}
				break;
			
			case 3: //locate the item
				
				if(itemList.empty())
				{
					cout << "The List is Empty" << endl;
				}else{
					Item toFind = getModelKey("Please Enter an item model to find: ");
					loc = itemList.find(toFind);
					if(loc==itemList.end()){
						cout<< "There are no "<<toFind.getModel()<<"'s in the list"<<endl;
					}else{
						cout<<toFind<<endl;
					}
				}
				break;


and in the item class I have these < than and == operators
Header file:
1
2
3
4
5
6
7
		bool operator<(const Item& v) const;


		bool operator==(const Item& itemRight);

//remaining code


and in the class file
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
bool Item::operator<(const Item& itemRight) const

	{
		
		if(getModel()<itemRight.getModel()){
			return true;
		}else{
			return false;
		}
	}

bool Item::operator==(const Item& itemRight)

{
	if(stricmp(getModel(),itemRight.getModel())!= 0){
		return false;
	}else{
		return true;

	}
}


The cases can never find the item
I tried changing set<Item>::const_iterator loc; to iterator<set<Item>::const_iterator,bool> loc; but then it says there are errors on the operands to the left of loc

any help? Any would be appreciated
Topic archived. No new replies allowed.