记录详情

Compile Error

foo.cc:85:19: error: redefinition of 'std::ostream& operator<<(std::ostream&, Vector&)'
   85 |  friend ostream & operator <<(ostream & out, Vector & v)
      |                   ^~~~~~~~
foo.cc:63:19: note: 'std::ostream& operator<<(std::ostream&, Vector&)' previously defined here
   63 |  friend ostream & operator <<(ostream & out, Vector & v)
      |                   ^~~~~~~~
foo.cc: In member function 'void Vector3Array::Input()':
foo.cc:105:11: error: cannot bind non-const lvalue reference of type 'Vector&' to an rvalue of type 'Vector'
  105 |    a[i++]=Vector(x,y,z);
      |           ^~~~~~~~~~~~~
foo.cc:75:27: note:   initializing argument 1 of 'void Vector::operator=(Vector&)'
   75 |  void operator =(Vector & v)
      |                  ~~~~~~~~~^
foo.cc: In member function 'void Vector3Array::sort()':
foo.cc:118:20: error: no matching function for call to 'swap(Vector&, Vector&)'
  118 |      swap(a[i],a[j]);
      |                    ^
In file included from /usr/include/c++/9/bits/nested_exception.h:40,
                 from /usr/include/c++/9/exception:144,
                 from /usr/include/c++/9/ios:39,
                 from /usr/include/c++/9/ostream:38,
                 from /usr/include/c++/9/iostream:39,
                 from foo.cc:10:
/usr/include/c++/9/bits/move.h:182:5: note: candidate: 'template<class _Tp> typename std::enable_if<std::__and_<std::__not_<std::__is_tuple_like<_Tp> >, std::is_move_constructible<_Tp>, std::is_move_assignable<_Tp> >::value>::type std::swap(_Tp&, _Tp&)'
  182 |     swap(_Tp& __a, _Tp& __b)
      |     ^~~~
/usr/include/c++/9/bits/move.h:182:5: note:   template argument deduction/substitution failed:
/usr/include/c++/9/bits/move.h: In substitution of 'template<class _Tp> typename std::enable_if<std::__and_<std::__not_<std::__is_tuple_like<_Tp> >, std::is_move_constructible<_Tp>, std::is_move_assignable<_Tp> >::value>::type std::swap(_Tp&, _Tp&) [with _Tp = Vector]':
foo.cc:118:20:   required from here
/usr/include/c++/9/bits/move.h:182:5: error: no type named 'type' in 'struct std::enable_if<false, void>'
/usr/include/c++/9/bits/move.h:205:5: note: candidate: 'template<class _Tp, long unsigned int _Nm> typename std::enable_if<std::__is_swappable<_Tp>::value>::type std::swap(_Tp (&)[_Nm], _Tp (&)[_Nm])'
  205 |     swap(_Tp (&__a)[_Nm], _Tp (&__b)[_Nm])
      |     ^~~~
/usr/include/c++/9/bits/move.h:205:5: note:   template argument deduction/substitution failed:
foo.cc:118:20: note:   mismatched types '_Tp [_Nm]' and 'Vector'
  118 |      swap(a[i],a[j]);
      |                    ^
In file included from /usr/include/c++/9/bits/stl_algobase.h:64,
                 from /usr/include/c++/9/bits/char_traits.h:39,
                 from /usr/include/c++/9/ios:40,
                 from /usr/include/c++/9/ostream:38,
                 from /usr/include/c++/9/iostream:39,
                 from foo.cc:10:
/usr/include/c++/9/bits/stl_pair.h:495:5: note: candidate: 'template<class _T1, class _T2> void std::swap(std::pair<_T1, _T2>&, std::pair<_T1, _T2>&)'
  495 |     swap(pair<_T1, _T2>& __x, pair<_T1, _T2>& __y)
      |     ^~~~
/usr/include/c++/9/bits/stl_pair.h:495:5: note:   template argument deduction/substitution failed:
foo.cc:118:20: note:   'Vector' is not derived from 'std::pair<_T1, _T2>'
  118 |      swap(a[i],a[j]);
      |                    ^
In file included from /usr/include/c++/9/string:55,
                 from /usr/include/c++/9/bits/locale_classes.h:40,
                 from /usr/include/c++/9/bits/ios_base.h:41,
                 from /usr/include/c++/9/ios:42,
                 from /usr/include/c++/9/ostream:38,
                 from /usr/include/c++/9/iostream:39,
                 from foo.cc:10:
/usr/include/c++/9/bits/basic_string.h:6381:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> void std::swap(std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&, std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&)'
 6381 |     swap(basic_string<_CharT, _Traits, _Alloc>& __lhs,
      |     ^~~~
/usr/include/c++/9/bits/basic_string.h:6381:5: note:   template argument deduction/substitution failed:
foo.cc:118:20: note:   'Vector' is not derived from 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>'
  118 |      swap(a[i],a[j]);
      |                    ^
[Hydro](https://hydro.ac)提供评测服务

信息

递交者
类型
递交
题目
P1018 OO4-2 向量的比较、赋值及向量集合类的排序
比赛
2022春 面向对象程序设计方法的上机作业
语言
C++
递交时间
2022-05-02 19:44:51
评测时间
2022-05-02 19:44:51
评测机
分数
0
总耗时
0ms
峰值内存
0 Bytes