std :: set.insert nie będzie się kompilował z klasą niestandardową [duplikat]

To pytanie ma już odpowiedź tutaj:

problemy z c ++ set container 2 odpowiedzi Nie można wstawić do std :: map (G ++) 1 odpowiedź

Mam klasę Record z trzema prywatnymi polami liczb całkowitych, obiektami pobierającymi i ustawiającymi oraz domyślnym i specyficznym konstruktorem. Mam zamiar wypełnić zestaw rekordami, ale mam problemy z uruchomieniem kodu.

#include <set>
using namespace std;

class Record
{
    int a, b, c;
    public:
    //getters and setters
    Record(){a = -1; b = -1; c = -1;};
}

int main()
{
    set< Record > s;
    s.insert(Record());
}

Próba kompilacji powoduje wystąpienie tego błędu:

C: \ Users \ Denton \ Documents \ Indiana University \ Class Documents \ Spring 2013 \ CSCI-H2 12 \ Assignment9> g ++ a9.cpp -o a9 W pliku dołączonym z c: \ mingw \ bin ../ lib / gcc / mingw32 / 4.6.2 / include / c ++ / string: 5 0: 0, z c: \ mingw \ bin ../ lib / gcc / mingw32 / 4.6.2 / include / c ++ / bits / loc ale_classes.h: 42, z c: \ mingw \ bin ../ lib / gcc / mingw32 / 4.6.2 / include / c ++ / bits / ios _base.h: 43, z c: \ mingw \ bin ../ lib / gcc / mingw32 / 4.6 .2 / include / c ++ / ios: 43, z c: \ mingw \ bin ../ lib / gcc / mingw32 / 4.6.2 / include / c ++ / ostream: 40, z c: \ mingw \ bin ../ lib /gcc/mingw32/4.6.2/include/c++/iostream: 40, od a9.cpp: 3: c: \ mingw \ bin ../ lib / gcc / mingw32 / 4.6.2 / include / c ++ / bits / stl_function .h: W funkcji składowej 'bool std :: less <_Tp> :: operator () (const _Tp &, const _Tp &) const [with _ Tp = Record]': c: \ mingw \ bin ../ lib / gcc / mingw32 / 4.6.2 / include / c ++ / bits / stl_tree.h: 1267: 4: inst antiated from 'std :: pair, bool> std :: _ Rb_tree <_Key, _Val, _KeyOfValue, _Compare, _Alloc> :: _ M_insert_unique ( const _Val &) [with _Key = Record, _Val = Record, _KeyOfValue = std :: _ Iden tity, _Compare = std :: l ess, _Alloc = std :: divator] 'c: \ mingw \ bin ../ lib / gcc / mingw32 / 4.6.2 / include / c ++ / bits / stl_set.h: 410: 29 : insta tated from 'std :: pair, _Compare, typ name _Alloc :: rebind <_Key> :: other> :: const_iterator, bool> std :: set <_Key, _Compare, _Alloc> :: insert (const typ_typu i) [z _Key = Record, _Compar e = std :: less, _Alloc = std :: alokator, nazwa typu std :: _ Rb_tree <_ Key, _Key, std :: _ Tożsamość <_Key>, _Compare, typ name _Alloc :: rebind <Key> :: inne> :: const_iterator = std :: _ Rb_tree_const_iterator, std :: set <_Key, _Compare, _Alloc> :: value_type = Record] 'a9.cpp: 72: 28: utworzony z tego miejsca c: \ mingw \ bin ../ lib /gcc/mingw32/4.6.2/include/c++/bits/stl_function.h:236:22: er ror: no match for 'operator <' w '__x <__y' c: \ mingw \ bin ../ lib / gcc / mingw32 / 4.6.2 / include / c ++ / bits / stl_function.h: 236: 22: no te: kandydaci to: c: \ mingw \ bin ../ lib / gcc / mingw32 / 4.6.2 / include / c ++ /bits/stl_pair.h:207:5: uwaga: t Outdate bool std :: operator <(const std :: pair <_T1, _T2> &, co nst std :: pair <_T1, _T2> i) c: \ mingw \ bin ../ lib / gcc / mingw32 / 4.6.2 / include / c ++ / bits / stl_iterator.h: 291: 5: not e: template bool std :: operator <(const std :: reverse_iterator <_It erator > &, const std :: reverse_iterator <_Iterator> &) c: \ mingw \ bin ../ lib / gcc / mingw32 / 4.6.2 / include / c ++ / bits / stl_iterator.h: 341: 5: not e: template bool std :: operator <(const std :: r everse_iterator <_IteratorL> &, const std :: reverse_iterator <_IteratorR> &) c: \ mingw \ bin ../ lib / gcc / mingw32 / 4.6.2 / include / c ++ /bits/basic_string.h:2510:5: no te: template bool std :: operator <(cons t std :: basic_string <_CharT, _Traits, _Alloc> &, const std :: basic_string <_CharT, _ Cechy, _Alloc> &) c: \ mingw \ bin ../ lib / gcc / mingw32 / 4.6.2 / include / c ++ / bits / basic_string.h: 2522: 5: no te: template bool std :: operator <(cons t std: : basic_string <_CharT, _Traits, _Alloc> &, const _CharT *) c: \ mingw \ bin ../ lib / gcc / mingw32 / 4.6.2 / include / c ++ / bits / basic_string.h: 2534: 5: no te : template bool std :: operator <(cons t _CharT *, const std :: basic_string <_CharT, _Traits, _Alloc> &) c: \ mingw \ bin ../ lib / gcc / mingw32 / 4. 6.2 / include / c ++ / bits / stl_vector.h: 1290: 5: note: template bool std :: operator <(const std :: vector <_Tp, _ Alloc> &, const std :: vector <_Tp, _Alloc> & ) c: \ mingw \ bin ../ lib / gcc / mingw32 / 4.6.2 / include / c ++ / bits / stl_list.h: 1593: 5: note: template bool std :: operator <(const std :: list < _Tp, _Allo c> &, const std :: list <_Tp, _Alloc> &) c: \ mingw \ bin ../ lib / gcc / mingw32 / 4.6.2 / include / c ++ / bits / stl_tree.h: 856: 5: Uwaga: t. c: \ mingw \ bin ../ lib / gcc / mingw32 / 4.6.2 / include / c ++ / bits / stl_set.h: 713: 5: note: te mplate bool std :: operator <(const std :: set < _Key, _Compare, _Alloc> &, const std :: set <_Key, _Compare, _Alloc> &) c: \ mingw \ bin ../ lib / gcc / mingw32 / 4.6.2 / include / c ++ / bits / stl_multiset.h : 696: 5: not e: template bool std :: operator <(const std :: multiset <_Key, _Compare, _Alloc> &, const std :: multiset <_Key, _Compare, _All oc> &)

insert działa dobrze, gdy tworzę zestaw s i s.insert (1) Co należy zrobić, aby ten kod się skompilował?

Z góry dziękuję

questionAnswers(1)

yourAnswerToTheQuestion