Compile Error

foo.cc: In function ‘int main()’:
foo.cc:13:21: warning: comparison with string literal results in unspecified behavior [-Waddress]
   13 |                 if(a=="km"&&b=="mm")
      |                    ~^~~~~~
foo.cc:13:21: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
foo.cc:13:30: warning: comparison with string literal results in unspecified behavior [-Waddress]
   13 |                 if(a=="km"&&b=="mm")
      |                             ~^~~~~~
foo.cc:13:30: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
foo.cc:15:26: warning: comparison with string literal results in unspecified behavior [-Waddress]
   15 |                 else if(a=="km"&&b=="m")
      |                         ~^~~~~~
foo.cc:15:26: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
foo.cc:15:35: warning: comparison with string literal results in unspecified behavior [-Waddress]
   15 |                 else if(a=="km"&&b=="m")
      |                                  ~^~~~~
foo.cc:15:35: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
foo.cc:17:26: warning: comparison with string literal results in unspecified behavior [-Waddress]
   17 |                 else if(a=="kg"&&b=="g")
      |                         ~^~~~~~
foo.cc:17:26: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
foo.cc:17:35: warning: comparison with string literal results in unspecified behavior [-Waddress]
   17 |                 else if(a=="kg"&&b=="g")
      |                                  ~^~~~~
foo.cc:17:35: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
foo.cc:20:21: warning: comparison with string literal results in unspecified behavior [-Waddress]
   20 |                 if(a=="kg"&&b=="mg")
      |                    ~^~~~~~
foo.cc:20:21: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
foo.cc:20:30: warning: comparison with string literal results in unspecified behavior [-Waddress]
   20 |                 if(a=="kg"&&b=="mg")
      |                             ~^~~~~~
foo.cc:20:30: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
foo.cc:24:38: error: no match for ‘operator*’ (operand types are ‘long long int’ and ‘std::string’ {aka ‘std::__cxx11::basic_string<char>’})
   24 |                 long long cnt=1LL*sum*x;
      |                               ~~~~~~~^~
      |                                  |    |
      |                                  |    std::string {aka std::__cxx11::basic_string<char>}
      |                                  long long int
foo.cc:24:38: note: there are 11 candidates
   24 |                 long long cnt=1LL*sum*x;
      |                               ~~~~~~~^~
In file included from /nix/gcc-15.2.0/include/c++/15.2.0/ccomplex:43,
                 from stdc++.h:133:
/nix/gcc-15.2.0/include/c++/15.2.0/complex:434:5: note: candidate 1: ‘template<class _Tp> std::complex<_Tp> std::operator*(const complex<_Tp>&, const complex<_Tp>&)’
  434 |     operator*(const complex<_Tp>& __x, const complex<_Tp>& __y)
      |     ^~~~~~~~
/nix/gcc-15.2.0/include/c++/15.2.0/complex:434:5: note: template argument deduction/substitution failed:
foo.cc:24:39: note:   mismatched types ‘const std::complex<_Tp>’ and ‘long long int’
   24 |                 long long cnt=1LL*sum*x;
      |                                       ^
/nix/gcc-15.2.0/include/c++/15.2.0/complex:443:5: note: candidate 2: ‘template<class _Tp> std::complex<_Tp> std::operator*(const complex<_Tp>&, const _Tp&)’
  443 |     operator*(const complex<_Tp>& __x, const _Tp& __y)
      |     ^~~~~~~~
/nix/gcc-15.2.0/include/c++/15.2.0/complex:443:5: note: template argument deduction/substitution failed:
foo.cc:24:39: note:   mismatched types ‘const std::complex<_Tp>’ and ‘long long int’
   24 |                 long long cnt=1LL*sum*x;
      |                                       ^
/nix/gcc-15.2.0/include/c++/15.2.0/complex:452:5: note: candidate 3: ‘template<class _Tp> std::complex<_Tp> std::operator*(const _Tp&, const complex<_Tp>&)’
  452 |     operator*(const _Tp& __x, const complex<_Tp>& __y)
      |     ^~~~~~~~
/nix/gcc-15.2.0/include/c++/15.2.0/complex:452:5: note: template argument deduction/substitution failed:
foo.cc:24:39: note:   ‘std::string’ {aka ‘std::__cxx11::basic_string<char>’} is not derived from ‘const std::complex<_Tp>’
   24 |                 long long cnt=1LL*sum*x;
      |                                       ^
In file included from /nix/gcc-15.2.0/include/c++/15.2.0/valarray:607,
                 from stdc++.h:169:
/nix/gcc-15.2.0/include/c++/15.2.0/bits/valarray_after.h:409:5: note: candidate 4: ‘template<class _Dom1, class _Dom2> std::_Expr<std::__detail::_BinClos<std::__multiplies, std::_Expr, std::_Expr, _Dom1, _Dom2>, typename std::__fun<std::__multiplies, typename _Dom1::value_type>::result_type> std::operator*(const _Expr<_Dom1, typename _Dom1::value_type>&, const _Expr<_Dom2, typename _Dom2::value_type>&)’
  409 |     _DEFINE_EXPR_BINARY_OPERATOR(*, struct std::__multiplies)
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/nix/gcc-15.2.0/include/c++/15.2.0/bits/valarray_after.h:409:5: note: template argument deduction/substitution failed:
foo.cc:24:39: note:   mismatched types ‘const std::_Expr<_Dom1, typename _Dom1::value_type>’ and ‘long long int’
   24 |                 long long cnt=1LL*sum*x;
      |                                       ^
/nix/gcc-15.2.0/include/c++/15.2.0/bits/valarray_after.h:409:5: note: candidate 5: ‘template<class _Dom> std::_Expr<std::__detail::_BinClos<std::__multiplies, std::_Expr, std::_Constant, _Dom, typename _Dom::value_type>, typename std::__fun<std::__multiplies, typename _Dom1::value_type>::result_type> std::operator*(const _Expr<_Dom1, typename _Dom1::value_type>&, const typename _Dom::value_type&)’
  409 |     _DEFINE_EXPR_BINARY_OPERATOR(*, struct std::__multiplies)
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/nix/gcc-15.2.0/include/c++/15.2.0/bits/valarray_after.h:409:5: note: template argument deduction/substitution failed:
foo.cc:24:39: note:   mismatched types ‘const std::_Expr<_Dom1, typename _Dom1::value_type>’ and ‘long long int’
   24 |                 long long cnt=1LL*sum*x;
      |                                       ^
/nix/gcc-15.2.0/include/c++/15.2.0/bits/valarray_after.h:409:5: note: candidate 6: ‘template<class _Dom> std::_Expr<std::__detail::_BinClos<std::__multiplies, std::_Constant, std::_Expr, typename _Dom::value_type, _Dom>, typename std::__fun<std::__multiplies, typename _Dom1::value_type>::result_type> std::operator*(const typename _Dom::value_type&, const _Expr<_Dom1, typename _Dom1::value_type>&)’
  409 |     _DEFINE_EXPR_BINARY_OPERATOR(*, struct std::__multiplies)
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/nix/gcc-15.2.0/include/c++/15.2.0/bits/valarray_after.h:409:5: note: template argument deduction/substitution failed:
foo.cc:24:39: note:   ‘std::string’ {aka ‘std::__cxx11::basic_string<char>’} is not derived from ‘const std::_Expr<_Dom1, typename _Dom1::value_type>’
   24 |                 long long cnt=1LL*sum*x;
      |                                       ^
/nix/gcc-15.2.0/include/c++/15.2.0/bits/valarray_after.h:409:5: note: candidate 7: ‘template<class _Dom> std::_Expr<std::__detail::_BinClos<std::__multiplies, std::_Expr, std::_ValArray, _Dom, typename _Dom::value_type>, typename std::__fun<std::__multiplies, typename _Dom1::value_type>::result_type> std::operator*(const _Expr<_Dom1, typename _Dom1::value_type>&, const valarray<typename _Dom::value_type>&)’
  409 |     _DEFINE_EXPR_BINARY_OPERATOR(*, struct std::__multiplies)
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/nix/gcc-15.2.0/include/c++/15.2.0/bits/valarray_after.h:409:5: note: template argument deduction/substitution failed:
foo.cc:24:39: note:   mismatched types ‘const std::_Expr<_Dom1, typename _Dom1::value_type>’ and ‘long long int’
   24 |                 long long cnt=1LL*sum*x;
      |                                       ^
/nix/gcc-15.2.0/include/c++/15.2.0/bits/valarray_after.h:409:5: note: candidate 8: ‘template<class _Dom> std::_Expr<std::__detail::_BinClos<std::__multiplies, std::_ValArray, std::_Expr, typename _Dom::value_type, _Dom>, typename std::__fun<std::__multiplies, typename _Dom1::value_type>::result_type> std::operator*(const valarray<typename _Dom::value_type>&, const _Expr<_Dom1, typename _Dom1::value_type>&)’
  409 |     _DEFINE_EXPR_BINARY_OPERATOR(*, struct std::__multiplies)
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/nix/gcc-15.2.0/include/c++/15.2.0/bits/valarray_after.h:409:5: note: template argument deduction/substitution failed:
foo.cc:24:39: note:   ‘std::string’ {aka ‘std::__cxx11::basic_string<char>’} is not derived from ‘const std::_Expr<_Dom1, typename _Dom1::value_type>’
   24 |                 long long cnt=1LL*sum*x;
      |                                       ^
/nix/gcc-15.2.0/include/c++/15.2.0/valarray:1200:1: note: candidate 9: ‘template<class _Tp> std::_Expr<std::__detail::_BinClos<std::__multiplies, std::_ValArray, std::_ValArray, _Tp, _Tp>, typename std::__fun<std::__multiplies, _Tp>::result_type> std::operator*(const valarray<_Tp>&, const valarray<_Tp>&)’
 1200 | _DEFINE_BINARY_OPERATOR(*, __multiplies)
      | ^~~~~~~~~~~~~~~~~~~~~~~
/nix/gcc-15.2.0/include/c++/15.2.0/valarray:1200:1: note: template argument deduction/substitution failed:
foo.cc:24:39: note:   mismatched types ‘const std::valarray<_Tp>’ and ‘long long int’
   24 |                 long long cnt=1LL*sum*x;
      |                                       ^
/nix/gcc-15.2.0/include/c++/15.2.0/valarray:1200:1: note: candidate 10: ‘template<class _Tp> std::_Expr<std::__detail::_BinClos<std::__multiplies, std::_ValArray, std::_Constant, _Tp, _Tp>, typename std::__fun<std::__multiplies, _Tp>::result_type> std::operator*(const valarray<_Tp>&, const typename valarray<_Tp>::value_type&)’
 1200 | _DEFINE_BINARY_OPERATOR(*, __multiplies)
      | ^~~~~~~~~~~~~~~~~~~~~~~
/nix/gcc-15.2.0/include/c++/15.2.0/valarray:1200:1: note: template argument deduction/substitution failed:
foo.cc:24:39: note:   mismatched types ‘const std::valarray<_Tp>’ and ‘long long int’
   24 |                 long long cnt=1LL*sum*x;
      |                                       ^
/nix/gcc-15.2.0/include/c++/15.2.0/valarray:1200:1: note: candidate 11: ‘template<class _Tp> std::_Expr<std::__detail::_BinClos<std::__multiplies, std::_Constant, std::_ValArray, _Tp, _Tp>, typename std::__fun<std::__multiplies, _Tp>::result_type> std::operator*(const typename valarray<_Tp>::value_type&, const valarray<_Tp>&)’
 1200 | _DEFINE_BINARY_OPERATOR(*, __multiplies)
      | ^~~~~~~~~~~~~~~~~~~~~~~
/nix/gcc-15.2.0/include/c++/15.2.0/valarray:1200:1: note: template argument deduction/substitution failed:
foo.cc:24:39: note:   ‘std::string’ {aka ‘std::__cxx11::basic_string<char>’} is not derived from ‘const std::valarray<_Tp>’
   24 |                 long long cnt=1LL*sum*x;
      |                                       ^

信息

递交者
类型
递交
题目
P2558 单位转换3级T2 2023.12
语言
C++
递交时间
2026-08-30 21:38:20
评测时间
2026-08-30 21:38:20
评测机
分数
0
总耗时
0ms
峰值内存
0 Bytes