|
|
back to boardWhy CE. I used set. I get CE. Why? #include <iostream> #include <vector> #include <sstream> #include <set> using namespace std; template < class TypeTree > class less_of_tree { public : ________bool operator () (TypeTree a, TypeTree b) ________{ ________________return a.name < b.name; ________} }; class tree { public : ________string name; ________set < tree, less_of_tree < tree > > child; ________tree (); ________tree (string s); ________void add (int x, vector < string > way); ________void print (string row); }; ... e:\judge\Judge\Vc7\include\xtree(988): error: no instance of function "less_of_tree<TypeTree>::operator() [with TypeTree=tree]" matches the argument list and object (the object has cv-qualifiers that prevent a match) argument types are: (const tree, const std::_Tree<std::_Tset_traits<tree, less_of_tree<tree>, std::allocator<tree>, false>>::key_type) object type is: const less_of_tree<tree> if (this->comp(_Key(_Pnode), _Keyval)) ^ detected during: instantiation of "std::_Tree<_Traits>::_Nodeptr std::_Tree<_Traits>::_Lbound(const std::_Tree<_Traits>::key_type &) const [with _Traits=std::_Tset_traits<tree, less_of_tree<tree>, std::allocator<tree>, false>]" at line 801 instantiation of "std::_Tree<_Traits>::iterator std::_Tree<_Traits>::lower_bound(const std::_Tree<_Traits>::key_type &) [with _Traits=std::_Tset_traits<tree, less_of_tree<tree>, std::allocator<tree>, false>]" at line 779 instantiation of "std::_Tree<_Traits>::iterator std::_Tree<_Traits>::find(const std::_Tree<_Traits>::key_type &) [with _Traits=std::_Tset_traits<tree, less_of_tree<tree>, std::allocator<tree>, false>]" at line 50 of "43d08e8e-4606-476a-85b3-38e5b7230ae9" Edited by author 10.05.2008 18:42 Re: Why CE. I used set. try to use 'const': template < class TypeTree > class less_of_tree { public : ________bool operator () (const TypeTree a, const TypeTree b) const // <-- here ________{ ________________return a.name < b.name; ________} }; Edited by author 10.05.2008 19:00 |
|
|