Compile Error

foo.cc: In member function 'A A::operator<(A) const':
foo.cc:9:25: error: could not convert '(((int)((const A*)this)->A::y) < ((int)b.A::y))' from 'bool' to 'A'
    9 |                 return y<b.y;
      |                        ~^~~~
      |                         |
      |                         bool
In file included from /nix/store/1x1q5sqa0ilbi8fz7aayk02pjy5g7jhh-gcc-12.3.0/include/c++/12.3.0/string:48,
                 from /nix/store/1x1q5sqa0ilbi8fz7aayk02pjy5g7jhh-gcc-12.3.0/include/c++/12.3.0/bits/locale_classes.h:40,
                 from /nix/store/1x1q5sqa0ilbi8fz7aayk02pjy5g7jhh-gcc-12.3.0/include/c++/12.3.0/bits/ios_base.h:41,
                 from /nix/store/1x1q5sqa0ilbi8fz7aayk02pjy5g7jhh-gcc-12.3.0/include/c++/12.3.0/ios:42,
                 from /nix/store/1x1q5sqa0ilbi8fz7aayk02pjy5g7jhh-gcc-12.3.0/include/c++/12.3.0/istream:38,
                 from /nix/store/1x1q5sqa0ilbi8fz7aayk02pjy5g7jhh-gcc-12.3.0/include/c++/12.3.0/sstream:38,
                 from /nix/store/1x1q5sqa0ilbi8fz7aayk02pjy5g7jhh-gcc-12.3.0/include/c++/12.3.0/complex:45,
                 from /nix/store/1x1q5sqa0ilbi8fz7aayk02pjy5g7jhh-gcc-12.3.0/include/c++/12.3.0/ccomplex:39,
                 from stdc++.h:54:
/nix/store/1x1q5sqa0ilbi8fz7aayk02pjy5g7jhh-gcc-12.3.0/include/c++/12.3.0/bits/stl_function.h: In instantiation of 'bool std::less<_Tp>::operator()(const _Tp&, const _Tp&) const [with _Tp = A]':
/nix/store/1x1q5sqa0ilbi8fz7aayk02pjy5g7jhh-gcc-12.3.0/include/c++/12.3.0/bits/stl_tree.h:2119:35:   required from 'std::pair<std::_Rb_tree_node_base*, std::_Rb_tree_node_base*> std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_get_insert_unique_pos(const key_type&) [with _Key = A; _Val = A; _KeyOfValue = std::_Identity<A>; _Compare = std::less<A>; _Alloc = std::allocator<A>; key_type = A]'
/nix/store/1x1q5sqa0ilbi8fz7aayk02pjy5g7jhh-gcc-12.3.0/include/c++/12.3.0/bits/stl_tree.h:2172:4:   required from 'std::pair<std::_Rb_tree_iterator<_Val>, bool> std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_insert_unique(_Arg&&) [with _Arg = const A&; _Key = A; _Val = A; _KeyOfValue = std::_Identity<A>; _Compare = std::less<A>; _Alloc = std::allocator<A>]'
/nix/store/1x1q5sqa0ilbi8fz7aayk02pjy5g7jhh-gcc-12.3.0/include/c++/12.3.0/bits/stl_set.h:512:25:   required from 'std::pair<typename std::_Rb_tree<_Key, _Key, std::_Identity<_Tp>, _Compare, typename __gnu_cxx::__alloc_traits<_Alloc>::rebind<_Key>::other>::const_iterator, bool> std::set<_Key, _Compare, _Alloc>::insert(const value_type&) [with _Key = A; _Compare = std::less<A>; _Alloc = std::allocator<A>; typename std::_Rb_tree<_Key, _Key, std::_Identity<_Tp>, _Compare, typename __gnu_cxx::__alloc_traits<_Alloc>::rebind<_Key>::other>::const_iterator = std::_Rb_tree<A, A, std::_Identity<A>, std::less<A>, std::allocator<A> >::const_iterator; typename __gnu_cxx::__alloc_traits<_Alloc>::rebind<_Key>::other = std::allocator<A>; typename __gnu_cxx::__alloc_traits<_Alloc>::rebind<_Key> = __gnu_cxx::__alloc_traits<std::allocator<A>, A>::rebind<A>; typename _Alloc::value_type = A; value_type = A]'
foo.cc:20:11:   required from here
/nix/store/1x1q5sqa0ilbi8fz7aayk02pjy5g7jhh-gcc-12.3.0/include/c++/12.3.0/bits/stl_function.h:408:22: error: cannot convert 'A' to 'bool' in return
  408 |       { return __x < __y; }
      |                      ^~~
[Hydro](https://hydro.ac)提供评测服务

信息

递交者
类型
递交
题目
P1997 NBA总冠军
语言
C++
递交时间
2023-09-08 20:47:23
评测时间
2023-09-08 20:47:23
评测机
分数
0
总耗时
0ms
峰值内存
0 Bytes