Compile Error

foo.cc: In function 'int main()':
foo.cc:14:16: error: 'n' was not declared in this scope
   14 | for(int i=1;i<=n;i++)
      |                ^
foo.cc:16:15: error: 'a' was not declared in this scope
   16 |          cin>>a[i];
      |               ^
foo.cc:20:12: error: invalid conversion from 'std::string*' {aka 'std::__cxx11::basic_string<char>*'} to 'char' [-fpermissive]
   20 |     str2 = str1;
      |            ^~~~
      |            |
      |            std::string* {aka std::__cxx11::basic_string<char>*}
In file included from /nix/store/np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0/include/c++/12.2.0/string:53,
                 from /nix/store/np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0/include/c++/12.2.0/bits/locale_classes.h:40,
                 from /nix/store/np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0/include/c++/12.2.0/bits/ios_base.h:41,
                 from /nix/store/np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0/include/c++/12.2.0/ios:42,
                 from /nix/store/np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0/include/c++/12.2.0/ostream:38,
                 from iostream:39:
/nix/store/np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0/include/c++/12.2.0/bits/basic_string.h:826:24: note:   initializing argument 1 of 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::operator=(_CharT) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]'
  826 |       operator=(_CharT __c)
      |                 ~~~~~~~^~~
foo.cc:24:14: error: no match for 'operator==' (operand types are 'std::string' {aka 'std::__cxx11::basic_string<char>'} and 'std::string [100000]' {aka 'std::__cxx11::basic_string<char> [100000]'})
   24 |     if (str2 == str1) //判断是否相等
      |         ~~~~ ^~ ~~~~
      |         |       |
      |         |       std::string [100000] {aka std::__cxx11::basic_string<char> [100000]}
      |         std::string {aka std::__cxx11::basic_string<char>}
In file included from /nix/store/np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0/include/c++/12.2.0/iosfwd:40,
                 from /nix/store/np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0/include/c++/12.2.0/ios:38:
/nix/store/np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0/include/c++/12.2.0/bits/postypes.h:192:5: note: candidate: 'template<class _StateT> bool std::operator==(const fpos<_StateT>&, const fpos<_StateT>&)'
  192 |     operator==(const fpos<_StateT>& __lhs, const fpos<_StateT>& __rhs)
      |     ^~~~~~~~
/nix/store/np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0/include/c++/12.2.0/bits/postypes.h:192:5: note:   template argument deduction/substitution failed:
foo.cc:24:17: note:   'std::string' {aka 'std::__cxx11::basic_string<char>'} is not derived from 'const std::fpos<_StateT>'
   24 |     if (str2 == str1) //判断是否相等
      |                 ^~~~
In file included from /nix/store/np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0/include/c++/12.2.0/string:41:
/nix/store/np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0/include/c++/12.2.0/bits/allocator.h:219:5: note: candidate: 'template<class _T1, class _T2> bool std::operator==(const allocator<_CharT>&, const allocator<_T2>&)'
  219 |     operator==(const allocator<_T1>&, const allocator<_T2>&)
      |     ^~~~~~~~
/nix/store/np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0/include/c++/12.2.0/bits/allocator.h:219:5: note:   template argument deduction/substitution failed:
foo.cc:24:17: note:   'std::string' {aka 'std::__cxx11::basic_string<char>'} is not derived from 'const std::allocator<_CharT>'
   24 |     if (str2 == str1) //判断是否相等
      |                 ^~~~
In file included from /nix/store/np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0/include/c++/12.2.0/string:47:
/nix/store/np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0/include/c++/12.2.0/bits/stl_iterator.h:444:5: note: candidate: 'template<class _Iterator> bool std::operator==(const reverse_iterator<_Iterator>&, const reverse_iterator<_Iterator>&)'
  444 |     operator==(const reverse_iterator<_Iterator>& __x,
      |     ^~~~~~~~
/nix/store/np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0/include/c++/12.2.0/bits/stl_iterator.h:444:5: note:   template argument deduction/substitution failed:
foo.cc:24:17: note:   'std::string' {aka 'std::__cxx11::basic_string<char>'} is not derived from 'const std::reverse_iterator<_Iterator>'
   24 |     if (str2 == str1) //判断是否相等
      |                 ^~~~
/nix/store/np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0/include/c++/12.2.0/bits/stl_iterator.h:489:5: note: candidate: 'template<class _IteratorL, class _IteratorR> bool std::operator==(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)'
  489 |     operator==(const reverse_iterator<_IteratorL>& __x,
      |     ^~~~~~~~
/nix/store/np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0/include/c++/12.2.0/bits/stl_iterator.h:489:5: note:   template argument deduction/substitution failed:
foo.cc:24:17: note:   'std::string' {aka 'std::__cxx11::basic_string<char>'} is not derived from 'const std::reverse_iterator<_Iterator>'
   24 |     if (str2 == str1) //判断是否相等
      |                 ^~~~
/nix/store/np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0/include/c++/12.2.0/bits/stl_iterator.h:1656:5: note: candidate: 'template<class _IteratorL, class _IteratorR> bool std::operator==(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)'
 1656 |     operator==(const move_iterator<_IteratorL>& __x,
      |     ^~~~~~~~
/nix/store/np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0/include/c++/12.2.0/bits/stl_iterator.h:1656:5: note:   template argument deduction/substitution failed:
foo.cc:24:17: note:   'std::string' {aka 'std::__cxx11::basic_string<char>'} is not derived from 'const std::move_iterator<_IteratorL>'
   24 |     if (str2 == str1) //判断是否相等
      |                 ^~~~
/nix/store/np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0/include/c++/12.2.0/bits/stl_iterator.h:1726:5: note: candidate: 'template<class _Iterator> bool std::operator==(const move_iterator<_IteratorL>&, const move_iterator<_IteratorL>&)'
 1726 |     operator==(const move_iterator<_Iterator>& __x,
      |     ^~~~~~~~
/nix/store/np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0/include/c++/12.2.0/bits/stl_iterator.h:1726:5: note:   template argument deduction/substitution failed:
foo.cc:24:17: note:   'std::string' {aka 'std::__cxx11::basic_string<char>'} is not derived from 'const std::move_iterator<_IteratorL>'
   24 |     if (str2 == str1) //判断是否相等
      |                 ^~~~
In file included from /nix/store/np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0/include/c++/12.2.0/bits/stl_algobase.h:64,
                 from /nix/store/np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0/include/c++/12.2.0/string:50:
/nix/store/np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0/include/c++/12.2.0/bits/stl_pair.h:640:5: note: candidate: 'template<class _T1, class _T2> constexpr bool std::operator==(const pair<_T1, _T2>&, const pair<_T1, _T2>&)'
  640 |     operator==(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
      |     ^~~~~~~~
/nix/store/np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0/include/c++/12.2.0/bits/stl_pair.h:640:5: note:   template argument deduction/substitution failed:
foo.cc:24:17: note:   'std::string' {aka 'std::__cxx11::basic_string<char>'} is not derived from 'const std::pair<_T1, _T2>'
   24 |     if (str2 == str1) //判断是否相等
      |                 ^~~~
/nix/store/np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0/include/c++/12.2.0/bits/basic_string.h:3575:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator==(const __cxx11::basic_string<_CharT, _Traits, _Alloc>&, const __cxx11::basic_string<_CharT, _Traits, _Alloc>&)'
 3575 |     operator==(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
      |     ^~~~~~~~
/nix/store/np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0/include/c++/12.2.0/bits/basic_string.h:3575:5: note:   template argument deduction/substitution failed:
foo.cc:24:17: note:   mismatched types 'const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>' and 'std::string [100000]' {aka 'std::__cxx11::basic_string<char> [100000]'}
   24 |     if (str2 == str1) //判断是否相等
      |                 ^~~~
/nix/store/np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0/include/c++/12.2.0/bits/basic_string.h:3584:5: note: candidate: 'template<class _CharT> typename __gnu_cxx::__enable_if<std::__is_char<_Tp>::__value, bool>::__type std::operator==(const __cxx11::basic_string<_CharT>&, const __cxx11::basic_string<_CharT>&)'
 3584 |     operator==(const basic_string<_CharT>& __lhs,
      |     ^~~~~~~~
/nix/store/np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0/include/c++/12.2.0/bits/basic_string.h:3584:5: note:   template argument deduction/substitution failed:
foo.cc:24:17: note:   mismatched types 'const std::__cxx11::basic_string<_CharT>' and 'std::string [100000]' {aka 'std::__cxx11::basic_string<char> [100000]'}
   24 |     if (str2 == str1) //判断是否相等
      |                 ^~~~
/nix/store/np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0/include/c++/12.2.0/bits/basic_string.h:3599:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator==(const __cxx11::basic_string<_CharT, _Traits, _Alloc>&, const _CharT*)'
 3599 |     operator==(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
      |     ^~~~~~~~
/nix/store/np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0/include/c++/12.2.0/bits/basic_string.h:3599:5: note:   template argument deduction/substitution failed:
foo.cc:24:17: note:   deduced conflicting types for parameter 'const _CharT' ('char' and 'std::string' {aka 'std::__cxx11::basic_string<char>'})
   24 |     if (str2 == str1) //判断是否相等
      |                 ^~~~
/nix/store/np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0/include/c++/12.2.0/bits/basic_string.h:3640:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator==(const _CharT*, const __cxx11::basic_string<_CharT, _Traits, _Alloc>&)'
 3640 |     operator==(const _CharT* __lhs,
      |     ^~~~~~~~
/nix/store/np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0/include/c++/12.2.0/bits/basic_string.h:3640:5: note:   template argument deduction/substitution failed:
foo.cc:24:17: note:   mismatched types 'const _CharT*' and 'std::__cxx11::basic_string<char>'
   24 |     if (str2 == str1) //判断是否相等
      |                 ^~~~
In file included from /nix/store/np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0/include/c++/12.2.0/bits/locale_facets.h:48,
                 from /nix/store/np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0/include/c++/12.2.0/bits/basic_ios.h:37,
                 from /nix/store/np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0/include/c++/12.2.0/ios:44:
/nix/store/np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0/include/c++/12.2.0/bits/streambuf_iterator.h:233:5: note: candidate: 'template<class _CharT, class _Traits> bool std::operator==(const istreambuf_iterator<_CharT, _Traits>&, const istreambuf_iterator<_CharT, _Traits>&)'
  233 |     operator==(const istreambuf_iterator<_CharT, _Traits>& __a,
      |     ^~~~~~~~
/nix/store/np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0/include/c++/12.2.0/bits/streambuf_iterator.h:233:5: note:   template argument deduction/substitution failed:
foo.cc:24:17: note:   'std::string' {aka 'std::__cxx11::basic_string<char>'} is not derived from 'const std::istreambuf_iterator<_CharT, _Traits>'
   24 |     if (str2 == str1) //判断是否相等
      |                 ^~~~
In file included from /nix/store/np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0/include/c++/12.2.0/x86_64-unknown-linux-gnu/bits/c++allocator.h:33,
                 from /nix/store/np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0/include/c++/12.2.0/bits/allocator.h:46:
/nix/store/np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0/include/c++/12.2.0/bits/new_allocator.h:196:9: note: candidate: 'template<class _Up> bool std::operator==(const __new_allocator<char>&, const __new_allocator<_Tp>&)'
  196 |         operator==(const __new_allocator&, const __new_allocator<_Up>&)
      |         ^~~~~~~~
/nix/store/np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0/include/c++/12.2.0/bits/new_allocator.h:196:9: note:   template argument deduction/substitution failed:
foo.cc:24:17: note:   mismatched types 'const std::__new_allocator<_Tp>' and 'std::string [100000]' {aka 'std::__cxx11::basic_string<char> [100000]'}
   24 |     if (str2 == str1) //判断是否相等
      |                 ^~~~
In file included from /nix/store/np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0/include/c++/12.2.0/bits/ios_base.h:46:
/nix/store/np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0/include/c++/12.2.0/system_error:362:3: note: candidate: 'bool std::operator==(const error_code&, const error_code&)'
  362 |   operator==(const error_code& __lhs, const error_code& __rhs) noexcept
      |   ^~~~~~~~
/nix/store/np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0/include/c++/12.2.0/system_error:362:32: note:   no known conversion for argument 1 from 'std::string' {aka 'std::__cxx11::basic_string<char>'} to 'const std::error_code&'
  362 |   operator==(const error_code& __lhs, const error_code& __rhs) noexcept
      |              ~~~~~~~~~~~~~~~~~~^~~~~
/nix/store/np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0/include/c++/12.2.0/system_error:368:3: note: candidate: 'bool std::operator==(const error_code&, const error_condition&)'
  368 |   operator==(const error_code& __lhs, const error_condition& __rhs) noexcept
      |   ^~~~~~~~
/nix/store/np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0/include/c++/12.2.0/system_error:368:32: note:   no known conversion for argument 1 from 'std::string' {aka 'std::__cxx11::basic_string<char>'} to 'const std::error_code&'
  368 |   operator==(const error_code& __lhs, const error_condition& __rhs) noexcept
      |              ~~~~~~~~~~~~~~~~~~^~~~~
/nix/store/np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0/include/c++/12.2.0/system_error:376:3: note: candidate: 'bool std::operator==(const error_condition&, const error_condition&)'
  376 |   operator==(const error_condition& __lhs,
      |   ^~~~~~~~
/nix/store/np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0/include/c++/12.2.0/system_error:376:37: note:   no known conversion for argument 1 from 'std::string' {aka 'std::__cxx11::basic_string<char>'} to 'const std::error_condition&'
  376 |   operator==(const error_condition& __lhs,
      |              ~~~~~~~~~~~~~~~~~~~~~~~^~~~~
/nix/store/np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0/include/c++/12.2.0/system_error:408:3: note: candidate: 'bool std::operator==(const error_condition&, const error_code&)'
  408 |   operator==(const error_condition& __lhs, const error_code& __rhs) noexcept
      |   ^~~~~~~~
/nix/store/np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0/include/c++/12.2.0/system_error:408:37: note:   no known conversion for argument 1 from 'std::string' {aka 'std::__cxx11::basic_string<char>'} to 'const std::error_condition&'
  408 |   operator==(const error_condition& __lhs, const error_code& __rhs) noexcept
      |              ~~~~~~~~~~~~~~~~~~~~~~~^~~~~
/nix/store/np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0/include/c++/12.2.0/bits/allocator.h:205:7: note: candidate: 'bool std::operator==(const allocator<char>&, const allocator<char>&)'
  205 |       operator==(const allocator&, const allocator&) _GLIBCXX_NOTHROW
      |       ^~~~~~~~
/nix/store/np14qqgvvnyna3vv640hmhi21flymiia-gcc-12.2.0/include/c++/12.2.0/bits/allocator.h:205:18: note:   no known conversion for argument 1 from 'std::string' {aka 'std::__cxx11::basic_string<char>'} to 'const std::allocator<char>&'
  205 |       operator==(const allocator&, const allocator&) _GLIBCXX_NOTHROW
      |                  ^~~~~~~~~~~~~~~~
[Hydro](https://hydro.ac)提供评测服务

信息

递交者
类型
递交
题目
P1087 3-6 查找资料
语言
C++
递交时间
2023-05-22 21:42:42
评测时间
2023-05-22 21:42:42
评测机
分数
0
总耗时
0ms
峰值内存
0 Bytes