Anyone help me out with why the following fails?
Code:int main(int argc, char *argv[]) { Node n(1,1); set<Node> mylist; mylist.insert(n); cout << "mylist.size() = " << mylist.size() << endl; return; }
Compile error ...
Code:g++ -o main main.cpp -I../includes main.cpp: In function ‘int main(int, char**)’: main.cpp:30:5: error: return-statement with no value, in function returning ‘int’ In file included from /usr/lib/gcc/x86_64-pc-linux-gnu/4.5.3/include/g++-v4/string:50:0, from main.cpp:10: /usr/lib/gcc/x86_64-pc-linux-gnu/4.5.3/include/g++-v4/bits/stl_function.h: In member function ‘bool std::less<_Tp>::operator()(const _Tp&, const _Tp&) const [with _Tp = Node]’: /usr/lib/gcc/x86_64-pc-linux-gnu/4.5.3/include/g++-v4/bits/stl_tree.h:1184:4: instantiated from ‘std::pair<std::_Rb_tree_iterator<_Val>, bool> std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_insert_unique(const _Val&) [with _Key = Node, _Val = Node, _KeyOfValue = std::_Identity<Node>, _Compare = std::less<Node>, _Alloc = std::allocator<Node>]’ /usr/lib/gcc/x86_64-pc-linux-gnu/4.5.3/include/g++-v4/bits/stl_set.h:408:29: instantiated from ‘std::pair<typename std::_Rb_tree<_Key, _Key, std::_Identity<_Key>, _Compare, typename _Alloc::rebind<_Key>::other>::const_iterator, bool> std::set<_Key, _Compare, _Alloc>::insert(const value_type&) [with _Key = Node, _Compare = std::less<Node>, _Alloc = std::allocator<Node>, typename std::_Rb_tree<_Key, _Key, std::_Identity<_Key>, _Compare, typename _Alloc::rebind<_Key>::other>::const_iterator = std::_Rb_tree_const_iterator<Node>, value_type = Node]’ main.cpp:26:20: instantiated from here /usr/lib/gcc/x86_64-pc-linux-gnu/4.5.3/include/g++-v4/bits/stl_function.h:230:22: error: no match for ‘operator<’ in ‘__x < __y’ make: *** [main] Error 1



1Likes
LinkBack URL
About LinkBacks



I used to be an adventurer like you... then I took an arrow to the knee.