2012-04-28 12 views
0

としてカスタム構造体で作業していないと削除します。 私は、インデックス、値だけを知りません。しかし、それは動作しません、それはおそらく私のカスタム構造体のために事業者に関係していますが、私はそれを修正する方法がわかりません。 stillAvailableは型のstd ::ベクトルとpreviousRound [J]であるは私がのstd ::削除とstd ::消去を使用して、ベクターから要素を削除しようとしていた値

stillAvailable.erase(remove(stillAvailable.begin(), stillAvailable.end(), previousRound[j]), stillAvailable.end()); 

がタイプチームは次のとおりです。

問題は、このコード行です。チームは次のようになります構造体です:

struct Team 
{ 
    int country; 
    std::string name; 
    int positionGP; 
    int groupID; 
}; 

私は次のようなエラーコードを取得する:

League.cc: In member function `bool League::generateSchema(int, std::vector<Team, std::allocator<Team> >)': 
League.cc:131: error: no match for 'operator*' in '*temp' 

C:/Dev-Cpp/include/c++/3.4.2/bits/stl_algo.h: In function `_OutputIterator std::remove_copy(_InputIterator, _InputIterator, _OutputIterator, const _Tp&) [with _InputIterator = __gnu_cxx::__normal_iterator<Team*, std::vector<Team, std::allocator<Team> > >, _OutputIterator = __gnu_cxx::__normal_iterator<Team*, std::vector<Team, std::allocator<Team> > >, _Tp = Team]': 
C:/Dev-Cpp/include/c++/3.4.2/bits/stl_algo.h:1114: instantiated from `_ForwardIterator std::remove(_ForwardIterator, _ForwardIterator, const _Tp&) [with _ForwardIterator = __gnu_cxx::__normal_iterator<Team*, std::vector<Team, std::allocator<Team> > >, _Tp = Team]' 
League.cc:145: instantiated from here 
C:/Dev-Cpp/include/c++/3.4.2/bits/stl_algo.h:1037: error: no match for 'operator==' in '(&__first)->__gnu_cxx::__normal_iterator<_Iterator, _Container>::operator* [with _Iterator = Team*, _Container = std::vector<Team, std::allocator<Team> >]() == __value' 

C:/Dev-Cpp/include/c++/3.4.2/bits/stl_algo.h: In function `_RandomAccessIterator std::find(_RandomAccessIterator, _RandomAccessIterator, const _Tp&, std::random_access_iterator_tag) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<Team*, std::vector<Team, std::allocator<Team> > >, _Tp = Team]': 
C:/Dev-Cpp/include/c++/3.4.2/bits/stl_algo.h:314: instantiated from `_InputIterator std::find(_InputIterator, _InputIterator, const _Tp&) [with _InputIterator = __gnu_cxx::__normal_iterator<Team*, std::vector<Team, std::allocator<Team> > >, _Tp = Team]' 
C:/Dev-Cpp/include/c++/3.4.2/bits/stl_algo.h:1112: instantiated from `_ForwardIterator std::remove(_ForwardIterator, _ForwardIterator, const _Tp&) [with _ForwardIterator = __gnu_cxx::__normal_iterator<Team*, std::vector<Team, std::allocator<Team> > >, _Tp = Team]' 

League.cc:145: instantiated from here 
C:/Dev-Cpp/include/c++/3.4.2/bits/stl_algo.h:207: error: no match for 'operator==' in '(&__first)->__gnu_cxx::__normal_iterator<_Iterator, _Container>::operator* [with _Iterator = Team*, _Container = std::vector<Team, std::allocator<Team> >]() == __val' 

C:/Dev-Cpp/include/c++/3.4.2/bits/stl_algo.h:211: error: no match for 'operator==' in '(&__first)->__gnu_cxx::__normal_iterator<_Iterator, _Container>::operator* [with _Iterator = Team*, _Container = std::vector<Team, std::allocator<Team> >]() == __val' 

C:/Dev-Cpp/include/c++/3.4.2/bits/stl_algo.h:215: error: no match for 'operator==' in '(&__first)->__gnu_cxx::__normal_iterator<_Iterator, _Container>::operator* [with _Iterator = Team*, _Container = std::vector<Team, std::allocator<Team> >]() == __val' 

C:/Dev-Cpp/include/c++/3.4.2/bits/stl_algo.h:219: error: no match for 'operator==' in '(&__first)->__gnu_cxx::__normal_iterator<_Iterator, _Container>::operator* [with _Iterator = Team*, _Container = std::vector<Team, std::allocator<Team> >]() == __val' 

C:/Dev-Cpp/include/c++/3.4.2/bits/stl_algo.h:227: error: no match for 'operator==' in '(&__first)->__gnu_cxx::__normal_iterator<_Iterator, _Container>::operator* [with _Iterator = Team*, _Container = std::vector<Team, std::allocator<Team> >]() == __val' 

C:/Dev-Cpp/include/c++/3.4.2/bits/stl_algo.h:231: error: no match for 'operator==' in '(&__first)->__gnu_cxx::__normal_iterator<_Iterator, _Container>::operator* [with _Iterator = Team*, _Container = std::vector<Team, std::allocator<Team> >]() == __val' 

C:/Dev-Cpp/include/c++/3.4.2/bits/stl_algo.h:235: error: no match for 'operator==' in '(&__first)->__gnu_cxx::__normal_iterator<_Iterator, _Container>::operator* [with _Iterator = Team*, _Container = std::vector<Team, std::allocator<Team> >]() == __val' 

任意の助けいただければ幸いです!前もって感謝します!

+0

133行目には何が書かれていますか?いくつかの(短縮された)コードを投稿してください。 –

答えて

0

std::removeは、あなたのクラスや構造体のために自動的にオーバーロードされていないoperator==を、使用しています。

bool operator==(const Team & lhs, const Team & rhs) 
{ 
    // compare lhs and rhs in such a way that you return true if they 
    // are equal, and false if they are not equal. You can define 
    // equal to mean whatever you want here. 
} 
+0

素晴らしい、ありがとう!私は、このような関数を定義する方法がわからなかったが、あなたの答えは非常に私を助けています!再度、感謝します! – rbnvrw

関連する問題