/ Vijos /

记录详情

Compile Error

foo.cc: In function 'int main()':
foo.cc:48:105: error: no match for 'operator+' (operand types are 'std::vector<Student>' and 'int')
   48 |     cout << students[0].name << endl << students[0].total_scholarship << endl << sum(students, students + n, 0) << endl;
      |                                                                                                ~~~~~~~~ ^ ~
      |                                                                                                |          |
      |                                                                                                |          int
      |                                                                                                std::vector<Student>
In file included from /nix/store/1x1q5sqa0ilbi8fz7aayk02pjy5g7jhh-gcc-12.3.0/include/c++/12.3.0/string:47,
                 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/ostream:38,
                 from iostream:39:
/nix/store/1x1q5sqa0ilbi8fz7aayk02pjy5g7jhh-gcc-12.3.0/include/c++/12.3.0/bits/stl_iterator.h:630:5: note: candidate: 'template<class _Iterator> std::reverse_iterator<_Iterator> std::operator+(typename reverse_iterator<_Iterator>::difference_type, const reverse_iterator<_Iterator>&)'
  630 |     operator+(typename reverse_iterator<_Iterator>::difference_type __n,
      |     ^~~~~~~~
/nix/store/1x1q5sqa0ilbi8fz7aayk02pjy5g7jhh-gcc-12.3.0/include/c++/12.3.0/bits/stl_iterator.h:630:5: note:   template argument deduction/substitution failed:
foo.cc:48:107: note:   mismatched types 'const std::reverse_iterator<_Iterator>' and 'int'
   48 |     cout << students[0].name << endl << students[0].total_scholarship << endl << sum(students, students + n, 0) << endl;
      |                                                                                                           ^
/nix/store/1x1q5sqa0ilbi8fz7aayk02pjy5g7jhh-gcc-12.3.0/include/c++/12.3.0/bits/stl_iterator.h:1804:5: note: candidate: 'template<class _Iterator> std::move_iterator<_IteratorL> std::operator+(typename move_iterator<_IteratorL>::difference_type, const move_iterator<_IteratorL>&)'
 1804 |     operator+(typename move_iterator<_Iterator>::difference_type __n,
      |     ^~~~~~~~
/nix/store/1x1q5sqa0ilbi8fz7aayk02pjy5g7jhh-gcc-12.3.0/include/c++/12.3.0/bits/stl_iterator.h:1804:5: note:   template argument deduction/substitution failed:
foo.cc:48:107: note:   mismatched types 'const std::move_iterator<_IteratorL>' and 'int'
   48 |     cout << students[0].name << endl << students[0].total_scholarship << endl << sum(students, students + n, 0) << endl;
      |                                                                                                           ^
In file included from /nix/store/1x1q5sqa0ilbi8fz7aayk02pjy5g7jhh-gcc-12.3.0/include/c++/12.3.0/string:53:
/nix/store/1x1q5sqa0ilbi8fz7aayk02pjy5g7jhh-gcc-12.3.0/include/c++/12.3.0/bits/basic_string.h:3440:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Alloc> std::operator+(const __cxx11::basic_string<_CharT, _Traits, _Alloc>&, const __cxx11::basic_string<_CharT, _Traits, _Alloc>&)'
 3440 |     operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
      |     ^~~~~~~~
/nix/store/1x1q5sqa0ilbi8fz7aayk02pjy5g7jhh-gcc-12.3.0/include/c++/12.3.0/bits/basic_string.h:3440:5: note:   template argument deduction/substitution failed:
foo.cc:48:107: note:   'std::vector<Student>' is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>'
   48 |     cout << students[0].name << endl << students[0].total_scholarship << endl << sum(students, students + n, 0) << endl;
      |                                                                                                           ^
In file included from /nix/store/1x1q5sqa0ilbi8fz7aayk02pjy5g7jhh-gcc-12.3.0/include/c++/12.3.0/string:54:
/nix/store/1x1q5sqa0ilbi8fz7aayk02pjy5g7jhh-gcc-12.3.0/include/c++/12.3.0/bits/basic_string.tcc:606:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Alloc> std::operator+(const _CharT*, const __cxx11::basic_string<_CharT, _Traits, _Alloc>&)'
  606 |     operator+(const _CharT* __lhs,
      |     ^~~~~~~~
/nix/store/1x1q5sqa0ilbi8fz7aayk02pjy5g7jhh-gcc-12.3.0/include/c++/12.3.0/bits/basic_string.tcc:606:5: note:   template argument deduction/substitution failed:
foo.cc:48:107: note:   mismatched types 'const _CharT*' and 'std::vector<Student>'
   48 |     cout << students[0].name << endl << students[0].total_scholarship << endl << sum(students, students + n, 0) << endl;
      |                                                                                                           ^
/nix/store/1x1q5sqa0ilbi8fz7aayk02pjy5g7jhh-gcc-12.3.0/include/c++/12.3.0/bits/basic_string.tcc:627:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Alloc> std::operator+(_CharT, const __cxx11::basic_string<_CharT, _Traits, _Alloc>&)'
  627 |     operator+(_CharT __lhs, const basic_string<_CharT, _Traits, _Alloc>& __rhs)
      |     ^~~~~~~~
/nix/store/1x1q5sqa0ilbi8fz7aayk02pjy5g7jhh-gcc-12.3.0/include/c++/12.3.0/bits/basic_string.tcc:627:5: note:   template argument deduction/substitution failed:
foo.cc:48:107: note:   mismatched types 'const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>' and 'int'
   48 |     cout << students[0].name << endl << students[0].total_scholarship << endl << sum(students, students + n, 0) << endl;
      |                                                                                                           ^
/nix/store/1x1q5sqa0ilbi8fz7aayk02pjy5g7jhh-gcc-12.3.0/include/c++/12.3.0/bits/basic_string.h:3480:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Alloc> std::operator+(const __cxx11::basic_string<_CharT, _Traits, _Alloc>&, const _CharT*)'
 3480 |     operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
      |     ^~~~~~~~
/nix/store/1x1q5sqa0ilbi8fz7aayk02pjy5g7jhh-gcc-12.3.0/include/c++/12.3.0/bits/basic_string.h:3480:5: note:   template argument deduction/substitution failed:
foo.cc:48:107: note:   'std::vector<Student>' is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>'
   48 |     cout << students[0].name << endl << students[0].total_scholarship << endl << sum(students, students + n, 0) << endl;
      |                                                                                                           ^
/nix/store/1x1q5sqa0ilbi8fz7aayk02pjy5g7jhh-gcc-12.3.0/include/c++/12.3.0/bits/basic_string.h:3497:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Alloc> std::operator+(const __cxx11::basic_string<_CharT, _Traits, _Alloc>&, _CharT)'
 3497 |     operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs, _CharT __rhs)
      |     ^~~~~~~~
/nix/store/1x1q5sqa0ilbi8fz7aayk02pjy5g7jhh-gcc-12.3.0/include/c++/12.3.0/bits/basic_string.h:3497:5: note:   template argument deduction/substitution failed:
foo.cc:48:107: note:   'std::vector<Student>' is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>'
   48 |     cout << students[0].name << endl << students[0].total_scholarship << endl << sum(students, students + n, 0) << endl;
      |                                                                                                           ^
/nix/store/1x1q5sqa0ilbi8fz7aayk02pjy5g7jhh-gcc-12.3.0/include/c++/12.3.0/bits/basic_string.h:3510:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Alloc> std::operator+(__cxx11::basic_string<_CharT, _Traits, _Alloc>&&, const __cxx11::basic_string<_CharT, _Traits, _Alloc>&)'
 3510 |     operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
      |     ^~~~~~~~
/nix/store/1x1q5sqa0ilbi8fz7aayk02pjy5g7jhh-gcc-12.3.0/include/c++/12.3.0/bits/basic_string.h:3510:5: note:   template argument deduction/substitution failed:
foo.cc:48:107: note:   'std::vector<Student>' is not derived from 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>'
   48 |     cout << students[0].name << endl << students[0].total_scholarship << endl << sum(students, students + n, 0) << endl;
      |                                                                                                           ^
/nix/store/1x1q5sqa0ilbi8fz7aayk02pjy5g7jhh-gcc-12.3.0/include/c++/12.3.0/bits/basic_string.h:3517:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Alloc> std::operator+(const __cxx11::basic_string<_CharT, _Traits, _Alloc>&, __cxx11::basic_string<_CharT, _Traits, _Alloc>&&)'
 3517 |     operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
      |     ^~~~~~~~
/nix/store/1x1q5sqa0ilbi8fz7aayk02pjy5g7jhh-gcc-12.3.0/include/c++/12.3.0/bits/basic_string.h:3517:5: note:   template argument deduction/substitution failed:
foo.cc:48:107: note:   'std::vector<Student>' is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>'
   48 |     cout << students[0].name << endl << students[0].total_scholarship << endl << sum(students, students + n, 0) << endl;
      |                                                                                                           ^
/nix/store/1x1q5sqa0ilbi8fz7aayk02pjy5g7jhh-gcc-12.3.0/include/c++/12.3.0/bits/basic_string.h:3524:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Alloc> std::operator+(__cxx11::basic_string<_CharT, _Traits, _Alloc>&&, __cxx11::basic_string<_CharT, _Traits, _Alloc>&&)'
 3524 |     operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
      |     ^~~~~~~~
/nix/store/1x1q5sqa0ilbi8fz7aayk02pjy5g7jhh-gcc-12.3.0/include/c++/12.3.0/bits/basic_string.h:3524:5: note:   template argument deduction/substitution failed:
foo.cc:48:107: note:   'std::vector<Student>' is not derived from 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>'
   48 |     cout << students[0].name << endl << students[0].total_scholarship << endl << sum(students, students + n, 0) << endl;
      |                                                                                                           ^
/nix/store/1x1q5sqa0ilbi8fz7aayk02pjy5g7jhh-gcc-12.3.0/include/c++/12.3.0/bits/basic_string.h:3547:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Alloc> std::operator+(const _CharT*, __cxx11::basic_string<_CharT, _Traits, _Alloc>&&)'
 3547 |     operator+(const _CharT* __lhs,
      |     ^~~~~~~~
/nix/store/1x1q5sqa0ilbi8fz7aayk02pjy5g7jhh-gcc-12.3.0/include/c++/12.3.0/bits/basic_string.h:3547:5: note:   template argument deduction/substitution failed:
foo.cc:48:107: note:   mismatched types 'const _CharT*' and 'std::vector<Student>'
   48 |     cout << students[0].name << endl << students[0].total_scholarship << endl << sum(students, students + n, 0) << endl;
      |                                                                                                           ^
/nix/store/1x1q5sqa0ilbi8fz7aayk02pjy5g7jhh-gcc-12.3.0/include/c++/12.3.0/bits/basic_string.h:3554:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Alloc> std::operator+(_CharT, __cxx11::basic_string<_CharT, _Traits, _Alloc>&&)'
 3554 |     operator+(_CharT __lhs,
      |     ^~~~~~~~
/nix/store/1x1q5sqa0ilbi8fz7aayk02pjy5g7jhh-gcc-12.3.0/include/c++/12.3.0/bits/basic_string.h:3554:5: note:   template argument deduction/substitution failed:
foo.cc:48:107: note:   mismatched types 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>' and 'int'
   48 |     cout << students[0].name << endl << students[0].total_scholarship << endl << sum(students, students + n, 0) << endl;
      |                                                                                                           ^
/nix/store/1x1q5sqa0ilbi8fz7aayk02pjy5g7jhh-gcc-12.3.0/include/c++/12.3.0/bits/basic_string.h:3561:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Alloc> std::operator+(__cxx11::basic_string<_CharT, _Traits, _Alloc>&&, const _CharT*)'
 3561 |     operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
      |     ^~~~~~~~
/nix/store/1x1q5sqa0ilbi8fz7aayk02pjy5g7jhh-gcc-12.3.0/include/c++/12.3.0/bits/basic_string.h:3561:5: note:   template argument deduction/substitution failed:
foo.cc:48:107: note:   'std::vector<Student>' is not derived from 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>'
   48 |     cout << students[0].name << endl << students[0].total_scholarship << endl << sum(students, students + n, 0) << endl;
      |                                                                                                           ^
/nix/store/1x1q5sqa0ilbi8fz7aayk02pjy5g7jhh-gcc-12.3.0/include/c++/12.3.0/bits/basic_string.h:3568:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Alloc> std::operator+(__cxx11::basic_string<_CharT, _Traits, _Alloc>&&, _CharT)'
 3568 |     operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
      |     ^~~~~~~~
/nix/store/1x1q5sqa0ilbi8fz7aayk02pjy5g7jhh-gcc-12.3.0/include/c++/12.3.0/bits/basic_string.h:3568:5: note:   template argument deduction/substitution failed:
foo.cc:48:107: note:   'std::vector<Student>' is not derived from 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>'
   48 |     cout << students[0].name << endl << students[0].total_scholarship << endl << sum(students, students + n, 0) << endl;
      |                                                                                                           ^
foo.cc:48:82: error: 'sum' was not declared in this scope
   48 |     cout << students[0].name << endl << students[0].total_scholarship << endl << sum(students, students + n, 0) << endl;
      |                                                                                  ^~~
[Hydro](https://hydro.ac)提供评测服务

信息

递交者
类型
递交
题目
P1001 谁拿了最多奖学金
语言
C++
递交时间
2023-08-31 21:54:34
评测时间
2023-08-31 21:54:35
评测机
分数
0
总耗时
0ms
峰值内存
0 Bytes