Here you have an iterator on your left. This is a container which, when dereference becomes an object, but it also has links to the other objects in the list.
On the right of your operator is a function which returns an
int
. An int can't be used like an iterator. It's incompatible.
You'll either need to:
1) Change SearchBrand() to return an iterator.
2) Find a suitable method to convert from the int to an iterator.
Assuming BrandName is a list<Brand>, your search function may look something like this:
1 2 3 4 5 6
|
list<Brand>::iterator SearchBrand(list<Brand>& bn)
{
for (list<Brand>::iterator it = br.begin(); it != br.end(); ++it)
if (bn->name = "Pick Me!")
return it;
}
|
If the integer is supposed to represent the index of the object in the list try this:
1 2
|
int i = SearchBrand(BrandName);
SomeBrandList.at(i);
|
Note that to use that code snippet, you'll need to use std::vector instead of std::list.