Compile Error

foo.cc: In function 'int main()':
foo.cc:6:6: error: no match for 'operator<<' (operand types are 'std::istream' {aka 'std::basic_istream<char>'} and 'int')
    6 |   cin<<a;
      |   ~~~^~~
      |   |    |
      |   |    int
      |   std::istream {aka std::basic_istream<char>}
foo.cc:6:6: note: candidate: 'operator<<(int, int)' (built-in)
    6 |   cin<<a;
      |   ~~~^~~
foo.cc:6:6: note:   no known conversion for argument 1 from 'std::istream' {aka 'std::basic_istream<char>'} to 'int'
In file included from /nix/store/r0n0bpr0s38f02hyg0akd63yxc1d2n86-gcc/include/c++/12.3.0/string:53,
                 from /nix/store/r0n0bpr0s38f02hyg0akd63yxc1d2n86-gcc/include/c++/12.3.0/bits/locale_classes.h:40,
                 from /nix/store/r0n0bpr0s38f02hyg0akd63yxc1d2n86-gcc/include/c++/12.3.0/bits/ios_base.h:41,
                 from /nix/store/r0n0bpr0s38f02hyg0akd63yxc1d2n86-gcc/include/c++/12.3.0/ios:42,
                 from /nix/store/r0n0bpr0s38f02hyg0akd63yxc1d2n86-gcc/include/c++/12.3.0/ostream:38,
                 from /nix/store/r0n0bpr0s38f02hyg0akd63yxc1d2n86-gcc/include/c++/12.3.0/iostream:39,
                 from foo.cc:2:
/nix/store/r0n0bpr0s38f02hyg0akd63yxc1d2n86-gcc/include/c++/12.3.0/bits/basic_string.h:3891:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::basic_ostream<_CharT, _Traits>& std::operator<<(basic_ostream<_CharT, _Traits>&, const __cxx11::basic_string<_CharT, _Traits, _Alloc>&)'
 3891 |     operator<<(basic_ostream<_CharT, _Traits>& __os,
      |     ^~~~~~~~
/nix/store/r0n0bpr0s38f02hyg0akd63yxc1d2n86-gcc/include/c++/12.3.0/bits/basic_string.h:3891:5: note:   template argument deduction/substitution failed:
foo.cc:6:8: note:   'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'std::basic_ostream<_CharT, _Traits>'
    6 |   cin<<a;
      |        ^
In file included from /nix/store/r0n0bpr0s38f02hyg0akd63yxc1d2n86-gcc/include/c++/12.3.0/bits/ios_base.h:46:
/nix/store/r0n0bpr0s38f02hyg0akd63yxc1d2n86-gcc/include/c++/12.3.0/system_error:335:5: note: candidate: 'template<class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::operator<<(basic_ostream<_CharT, _Traits>&, const error_code&)'
  335 |     operator<<(basic_ostream<_CharT, _Traits>& __os, const error_code& __e)
      |     ^~~~~~~~
/nix/store/r0n0bpr0s38f02hyg0akd63yxc1d2n86-gcc/include/c++/12.3.0/system_error:335:5: note:   template argument deduction/substitution failed:
foo.cc:6:8: note:   'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'std::basic_ostream<_CharT, _Traits>'
    6 |   cin<<a;
      |        ^
/nix/store/r0n0bpr0s38f02hyg0akd63yxc1d2n86-gcc/include/c++/12.3.0/ostream:507:5: note: candidate: 'template<class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::operator<<(basic_ostream<_CharT, _Traits>&, _CharT)'
  507 |     operator<<(basic_ostream<_CharT, _Traits>& __out, _CharT __c)
      |     ^~~~~~~~
/nix/store/r0n0bpr0s38f02hyg0akd63yxc1d2n86-gcc/include/c++/12.3.0/ostream:507:5: note:   template argument deduction/substitution failed:
foo.cc:6:8: note:   'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'std::basic_ostream<_CharT, _Traits>'
    6 |   cin<<a;
      |        ^
/nix/store/r0n0bpr0s38f02hyg0akd63yxc1d2n86-gcc/include/c++/12.3.0/ostream:517:5: note: candidate: 'template<class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::operator<<(basic_ostream<_CharT, _Traits>&, char)'
  517 |     operator<<(basic_ostream<_CharT, _Traits>& __out, char __c)
      |     ^~~~~~~~
/nix/store/r0n0bpr0s38f02hyg0akd63yxc1d2n86-gcc/include/c++/12.3.0/ostream:517:5: note:   template argument deduction/substitution failed:
foo.cc:6:8: note:   'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'std::basic_ostream<_CharT, _Traits>'
    6 |   cin<<a;
      |        ^
/nix/store/r0n0bpr0s38f02hyg0akd63yxc1d2n86-gcc/include/c++/12.3.0/ostream:523:5: note: candidate: 'template<class _Traits> std::basic_ostream<char, _Traits>& std::operator<<(basic_ostream<char, _Traits>&, char)'
  523 |     operator<<(basic_ostream<char, _Traits>& __out, char __c)
      |     ^~~~~~~~
/nix/store/r0n0bpr0s38f02hyg0akd63yxc1d2n86-gcc/include/c++/12.3.0/ostream:523:5: note:   template argument deduction/substitution failed:
foo.cc:6:8: note:   'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'std::basic_ostream<char, _Traits>'
    6 |   cin<<a;
      |        ^
/nix/store/r0n0bpr0s38f02hyg0akd63yxc1d2n86-gcc/include/c++/12.3.0/ostream:534:5: note: candidate: 'template<class _Traits> std::basic_ostream<char, _Traits>& std::operator<<(basic_ostream<char, _Traits>&, signed char)'
  534 |     operator<<(basic_ostream<char, _Traits>& __out, signed char __c)
      |     ^~~~~~~~
/nix/store/r0n0bpr0s38f02hyg0akd63yxc1d2n86-gcc/include/c++/12.3.0/ostream:534:5: note:   template argument deduction/substitution failed:
foo.cc:6:8: note:   'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'std::basic_ostream<char, _Traits>'
    6 |   cin<<a;
      |        ^
/nix/store/r0n0bpr0s38f02hyg0akd63yxc1d2n86-gcc/include/c++/12.3.0/ostream:539:5: note: candidate: 'template<class _Traits> std::basic_ostream<char, _Traits>& std::operator<<(basic_ostream<char, _Traits>&, unsigned char)'
  539 |     operator<<(basic_ostream<char, _Traits>& __out, unsigned char __c)
      |     ^~~~~~~~
/nix/store/r0n0bpr0s38f02hyg0akd63yxc1d2n86-gcc/include/c++/12.3.0/ostream:539:5: note:   template argument deduction/substitution failed:
foo.cc:6:8: note:   'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'std::basic_ostream<char, _Traits>'
    6 |   cin<<a;
      |        ^
/nix/store/r0n0bpr0s38f02hyg0akd63yxc1d2n86-gcc/include/c++/12.3.0/ostream:598:5: note: candidate: 'template<class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::operator<<(basic_ostream<_CharT, _Traits>&, const _CharT*)'
  598 |     operator<<(basic_ostream<_CharT, _Traits>& __out, const _CharT* __s)
      |     ^~~~~~~~
/nix/store/r0n0bpr0s38f02hyg0akd63yxc1d2n86-gcc/include/c++/12.3.0/ostream:598:5: note:   template argument deduction/substitution failed:
foo.cc:6:8: note:   'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'std::basic_ostream<_CharT, _Traits>'
    6 |   cin<<a;
      |        ^
In file included from /nix/store/r0n0bpr0s38f02hyg0akd63yxc1d2n86-gcc/include/c++/12.3.0/ostream:833:
/nix/store/r0n0bpr0s38f02hyg0akd63yxc1d2n86-gcc/include/c++/12.3.0/bits/ostream.tcc:307:5: note: candidate: 'template<class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::operator<<(basic_ostream<_CharT, _Traits>&, const char*)'
  307 |     operator<<(basic_ostream<_CharT, _Traits>& __out, const char* __s)
      |     ^~~~~~~~
/nix/store/r0n0bpr0s38f02hyg0akd63yxc1d2n86-gcc/include/c++/12.3.0/bits/ostream.tcc:307:5: note:   template argument deduction/substitution failed:
foo.cc:6:8: note:   'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'std::basic_ostream<_CharT, _Traits>'
    6 |   cin<<a;
      |        ^
/nix/store/r0n0bpr0s38f02hyg0akd63yxc1d2n86-gcc/include/c++/12.3.0/ostream:615:5: note: candidate: 'template<class _Traits> std::basic_ostream<char, _Traits>& std::operator<<(basic_ostream<char, _Traits>&, const char*)'
  615 |     operator<<(basic_ostream<char, _Traits>& __out, const char* __s)
      |     ^~~~~~~~
/nix/store/r0n0bpr0s38f02hyg0akd63yxc1d2n86-gcc/include/c++/12.3.0/ostream:615:5: note:   template argument deduction/substitution failed:
foo.cc:6:8: note:   'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'std::basic_ostream<char, _Traits>'
    6 |   cin<<a;
      |        ^
/nix/store/r0n0bpr0s38f02hyg0akd63yxc1d2n86-gcc/include/c++/12.3.0/ostream:628:5: note: candidate: 'template<class _Traits> std::basic_ostream<char, _Traits>& std::operator<<(basic_ostream<char, _Traits>&, const signed char*)'
  628 |     operator<<(basic_ostream<char, _Traits>& __out, const signed char* __s)
      |     ^~~~~~~~
/nix/store/r0n0bpr0s38f02hyg0akd63yxc1d2n86-gcc/include/c++/12.3.0/ostream:628:5: note:   template argument deduction/substitution failed:
foo.cc:6:8: note:   'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'std::basic_ostream<char, _Traits>'
    6 |   cin<<a;
      |        ^
/nix/store/r0n0bpr0s38f02hyg0akd63yxc1d2n86-gcc/include/c++/12.3.0/ostream:633:5: note: candidate: 'template<class _Traits> std::basic_ostream<char, _Traits>& std::operator<<(basic_ostream<char, _Traits>&, const unsigned char*)'
  633 |     operator<<(basic_ostream<char, _Traits>& __out, const unsigned char* __s)
      |     ^~~~~~~~
/nix/store/r0n0bpr0s38f02hyg0akd63yxc1d2n86-gcc/include/c++/12.3.0/ostream:633:5: note:   template argument deduction/substitution failed:
foo.cc:6:8: note:   'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'std::basic_ostream<char, _Traits>'
    6 |   cin<<a;
      |        ^
/nix/store/r0n0bpr0s38f02hyg0akd63yxc1d2n86-gcc/include/c++/12.3.0/ostream:754:5: note: candidate: 'template<class _Ostream, class _Tp> _Ostream&& std::operator<<(_Ostream&&, const _Tp&)'
  754 |     operator<<(_Ostream&& __os, const _Tp& __x)
      |     ^~~~~~~~
/nix/store/r0n0bpr0s38f02hyg0akd63yxc1d2n86-gcc/include/c++/12.3.0/ostream:754:5: note:   template argument deduction/substitution failed:
/nix/store/r0n0bpr0s38f02hyg0akd63yxc1d2n86-gcc/include/c++/12.3.0/ostream: In substitution of 'template<class _Ostream, class _Tp> _Ostream&& std::operator<<(_Ostream&&, const _Tp&) [with _Ostream = std::basic_istream<char>&; _Tp = int]':
foo.cc:6:8:   required from here
/nix/store/r0n0bpr0s38f02hyg0akd63yxc1d2n86-gcc/include/c++/12.3.0/ostream:754:5: error: no type named 'type' in 'struct std::enable_if<false, void>'
[Hydro](https://hydro.ac)提供评测服务

信息

递交者
类型
递交
题目
P1003 求一个整数的各位数字之和。
语言
C++
递交时间
2023-11-09 21:29:22
评测时间
2023-11-09 21:29:22
评测机
分数
0
总耗时
0ms
峰值内存
0 Bytes