记录详情

Compile Error

foo.cc:25:20: error: flexible array member 'ComplexArray::a' in an otherwise empty 'class ComplexArray'
   25 |    vector<Complex> a[];
      |                    ^
foo.cc: In constructor 'ComplexArray::ComplexArray(int)':
foo.cc:30:33: error: unknown array size in delete
   30 | ComplexArray::ComplexArray(int n)
      |                                 ^
foo.cc: In destructor 'ComplexArray::~ComplexArray()':
foo.cc:23:7: error: unknown array size in delete
   23 | class ComplexArray
      |       ^~~~~~~~~~~~
foo.cc: In function 'int main()':
foo.cc:115:21: note: synthesized method 'ComplexArray::~ComplexArray()' first required here
  115 |     ComplexArray c(n);
      |                     ^
In file included 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:1:
/usr/include/c++/9/bits/stl_algobase.h: In instantiation of 'static _OI std::__copy_move<false, false, std::random_access_iterator_tag>::__copy_m(_II, _II, _OI) [with _II = const Complex*; _OI = Complex*]':
/usr/include/c++/9/bits/stl_algobase.h:404:30:   required from '_OI std::__copy_move_a(_II, _II, _OI) [with bool _IsMove = false; _II = const Complex*; _OI = Complex*]'
/usr/include/c++/9/bits/stl_algobase.h:441:30:   required from '_OI std::__copy_move_a2(_II, _II, _OI) [with bool _IsMove = false; _II = __gnu_cxx::__normal_iterator<const Complex*, std::vector<Complex> >; _OI = __gnu_cxx::__normal_iterator<Complex*, std::vector<Complex> >]'
/usr/include/c++/9/bits/stl_algobase.h:474:7:   required from '_OI std::copy(_II, _II, _OI) [with _II = __gnu_cxx::__normal_iterator<const Complex*, std::vector<Complex> >; _OI = __gnu_cxx::__normal_iterator<Complex*, std::vector<Complex> >]'
/usr/include/c++/9/bits/vector.tcc:238:31:   required from 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(const std::vector<_Tp, _Alloc>&) [with _Tp = Complex; _Alloc = std::allocator<Complex>]'
foo.cc:47:27:   required from here
/usr/include/c++/9/bits/stl_algobase.h:342:18: error: binding reference of type 'Complex&' to 'const Complex' discards qualifiers
  342 |        *__result = *__first;
      |        ~~~~~~~~~~^~~~~~~~~~
foo.cc:94:39: note:   initializing argument 1 of 'Complex Complex::operator=(Complex&)'
   94 | Complex Complex::operator = (Complex& m)
      |                              ~~~~~~~~~^
In file included from /usr/include/c++/9/bits/stl_algobase.h:71,
                 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:1:
/usr/include/c++/9/bits/predefined_ops.h: In instantiation of 'bool __gnu_cxx::__ops::_Iter_less_iter::operator()(_Iterator1, _Iterator2) const [with _Iterator1 = const Complex*; _Iterator2 = const Complex*]':
/usr/include/c++/9/bits/stl_algobase.h:903:14:   required from 'bool std::__lexicographical_compare_impl(_II1, _II1, _II2, _II2, _Compare) [with _II1 = const Complex*; _II2 = const Complex*; _Compare = __gnu_cxx::__ops::_Iter_less_iter]'
/usr/include/c++/9/bits/stl_algobase.h:924:44:   required from 'static bool std::__lexicographical_compare<_BoolType>::__lc(_II1, _II1, _II2, _II2) [with _II1 = const Complex*; _II2 = const Complex*; bool _BoolType = false]'
/usr/include/c++/9/bits/stl_algobase.h:960:60:   required from 'bool std::__lexicographical_compare_aux(_II1, _II1, _II2, _II2) [with _II1 = const Complex*; _II2 = const Complex*]'
/usr/include/c++/9/bits/stl_algobase.h:1256:48:   required from 'bool std::lexicographical_compare(_II1, _II1, _II2, _II2) [with _II1 = __gnu_cxx::__normal_iterator<const Complex*, std::vector<Complex> >; _II2 = __gnu_cxx::__normal_iterator<const Complex*, std::vector<Complex> >]'
/usr/include/c++/9/bits/stl_vector.h:1906:42:   required from 'bool std::operator<(const std::vector<_Tp, _Alloc>&, const std::vector<_Tp, _Alloc>&) [with _Tp = Complex; _Alloc = std::allocator<Complex>]'
/usr/include/c++/9/bits/stl_vector.h:1919:18:   required from 'bool std::operator>(const std::vector<_Tp, _Alloc>&, const std::vector<_Tp, _Alloc>&) [with _Tp = Complex; _Alloc = std::allocator<Complex>]'
foo.cc:45:27:   required from here
/usr/include/c++/9/bits/predefined_ops.h:43:23: error: no match for 'operator<' (operand types are 'const Complex' and 'const Complex')
   43 |       { return *__it1 < *__it2; }
      |                ~~~~~~~^~~~~~~~
foo.cc:78:6: note: candidate: 'bool Complex::operator<(Complex&)' <near match>
   78 | bool Complex::operator < (Complex& m)
      |      ^~~~~~~
foo.cc:78:6: note:   conversion of argument 1 would be ill-formed:
In file included from /usr/include/c++/9/bits/stl_algobase.h:71,
                 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:1:
/usr/include/c++/9/bits/predefined_ops.h:43:23: error: binding reference of type 'Complex&' to 'const Complex' discards qualifiers
   43 |       { return *__it1 < *__it2; }
      |                ~~~~~~~^~~~~~~~
In file included from /usr/include/c++/9/bits/stl_algobase.h:67,
                 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:1:
/usr/include/c++/9/bits/stl_iterator.h:912:5: note: candidate: 'template<class _IteratorL, class _IteratorR, class _Container> bool __gnu_cxx::operator<(const __gnu_cxx::__normal_iterator<_IteratorL, _Container>&, const __gnu_cxx::__normal_iterator<_IteratorR, _Container>&)'
  912 |     operator<(const __normal_iterator<_IteratorL, _Container>& __lhs,
      |     ^~~~~~~~
/usr/include/c++/9/bits/stl_iterator.h:912:5: note:   template argument deduction/substitution failed:
In file included from /usr/include/c++/9/bits/stl_algobase.h:71,
                 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:1:
/usr/include/c++/9/bits/predefined_ops.h:43:23: note:   'const Complex' is not derived from 'const __gnu_cxx::__normal_iterator<_IteratorL, _Container>'
   43 |       { return *__it1 < *__it2; }
      |                ~~~~~~~^~~~~~~~
In file included from /usr/include/c++/9/bits/stl_algobase.h:67,
                 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:1:
/usr/include/c++/9/bits/stl_iterator.h:919:5: note: candidate: 'template<class _Iterator, class _Container> bool __gnu_cxx::operator<(const __gnu_cxx::__normal_iterator<_Iterator, _Container>&, const __gnu_cxx::__normal_iterator<_Iterator, _Container>&)'
  919 |     operator<(const __normal_iterator<_Iterator, _Container>& __lhs,
      |     ^~~~~~~~
/usr/include/c++/9/bits/stl_iterator.h:919:5: note:   template argument deduction/substitution failed:
In file included from /usr/include/c++/9/bits/stl_algobase.h:71,
                 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:1:
/usr/include/c++/9/bits/predefined_ops.h:43:23: note:   'const Complex' is not derived from 'const __gnu_cxx::__normal_iterator<_Iterator, _Container>'
   43 |       { return *__it1 < *__it2; }
      |                ~~~~~~~^~~~~~~~
[Hydro](https://hydro.ac)提供评测服务

信息

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