[C++] find() + listy z STL

0

Witam, mam nastepujacy problem:
napisalem sobie mala klase CostTile ze zdefiniowanym operatorem

int operator==(CostTile& a, CostTile& b)

, potem tworze obiekt tej klasy

::CostTile neighboor;

i jakos go inicjalizuje.
Nastepnie jest:

std::find(closed.begin(), closed.end(),neighboor);

i na tej linijce mi sie wywala.
MSVC.NET daje komunikat bledu:

binary '==' : no operator found which takes a left-hand operand of type 'std::allocator<_Ty>::value_type' (or there is no acceptable conversion)
with
[
_Ty=CostTile
]
f:\Temp\modules\engine\ctilemap.cpp(141) : see reference to function template instantiation '_InIt std::find<_Ty>::iterator,CostTile>(_InIt,_InIt,const _Ty &)' being compiled
with
[
_InIt=std::list::iterator,
_Ty=CostTile
]

Nie bardzo rozumiem ten blad. Prosze o pomoc. </quote></cpp>

0

Przyklad testowany w BCB 6.0

#include <iostream>
#include <algorithms>

using namespace std;

class Klasa
{
 private:
  int wartosc;
 public:
  Klasa(int w) : wartosc(w){}
  bool operator==(const Klasa & kl)
  {
    return wartosc == kl.wartosc;
  }
  void wypisz()
  {
    cout << wartosc << endl;
  }
};

int main()
{
  Klasa tablica[] = {Klasa(2), Klasa(3), Klasa(3), Klasa(10), Klasa(7)};
  Klasa element(3);
  int n = sizeof(tablica) / sizeof(Klasa) - 1;
  find(tablica, tablica + n, element)->wypisz();
  cin.get();
  return 0;
}

1 użytkowników online, w tym zalogowanych: 0, gości: 1