记录详情

Compile Error

foo.cc: In member function 'Complex Complex::operator*(Complex&)':
foo.cc:31:7: warning: unused variable 'rr' [-Wunused-variable]
   31 |   int rr = c.re, ii = c.im;
      |       ^~
foo.cc:31:18: warning: unused variable 'ii' [-Wunused-variable]
   31 |   int rr = c.re, ii = c.im;
      |                  ^~
foo.cc: In member function 'void ComplexArray::Input()':
foo.cc:68:9: error: cannot bind non-const lvalue reference of type 'Complex&' to an rvalue of type 'Complex'
   68 |    c[i]=Complex(x,y);
      |         ^~~~~~~~~~~~
foo.cc:37:28: note:   initializing argument 1 of 'void Complex::operator=(Complex&)'
   37 |  void operator = (Complex &c)
      |                   ~~~~~~~~~^
foo.cc: In member function 'void ComplexArray::sort()':
foo.cc:83:22: error: no matching function for call to 'swap(Complex&, Complex&)'
   83 |      swap(c[j],c[j-1]);
      |                      ^
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:6:
/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 = Complex]':
foo.cc:83:22:   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:83:22: note:   mismatched types '_Tp [_Nm]' and 'Complex'
   83 |      swap(c[j],c[j-1]);
      |                      ^
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:6:
/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:83:22: note:   'Complex' is not derived from 'std::pair<_T1, _T2>'
   83 |      swap(c[j],c[j-1]);
      |                      ^
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:6:
/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:83:22: note:   'Complex' is not derived from 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>'
   83 |      swap(c[j],c[j-1]);
      |                      ^
foo.cc:85:7: error: 'i' was not declared in this scope
   85 |   for(i = 0; i<n; i++)
      |       ^
[Hydro](https://hydro.ac)提供评测服务

信息

递交者
类型
递交
题目
P1013 OO2-3 复数数组类的冒泡排序
比赛
2022春 面向对象程序设计方法的上机作业
语言
C++
递交时间
2022-05-01 11:27:16
评测时间
2022-05-01 11:27:16
评测机
分数
0
总耗时
0ms
峰值内存
0 Bytes