/ Vijos /

记录详情

Compile Error

foo.cc: In function ‘int main()’:
foo.cc:21:32: error: ‘to_string’ was not declared in this scope; did you mean ‘std::__cxx11::to_string’?
   21 |                  vec.push_back(to_string(i));
      |                                ^~~~~~~~~
      |                                std::__cxx11::to_string
In file included from /nix/gcc-13.3.0/include/c++/13.3.0/string:54,
                 from /nix/gcc-13.3.0/include/c++/13.3.0/bits/locale_classes.h:40,
                 from /nix/gcc-13.3.0/include/c++/13.3.0/bits/ios_base.h:41,
                 from /nix/gcc-13.3.0/include/c++/13.3.0/ios:44,
                 from /nix/gcc-13.3.0/include/c++/13.3.0/ostream:40,
                 from iostream:41:
/nix/gcc-13.3.0/include/c++/13.3.0/bits/basic_string.h:4261:3: note: ‘std::__cxx11::to_string’ declared here
 4261 |   to_string(long double __val)
      |   ^~~~~~~~~
foo.cc:22:21: error: no match for ‘operator+=’ (operand types are ‘std::string’ {aka ‘std::__cxx11::basic_string<char>’} and ‘std::vector<std::__cxx11::basic_string<char> >’)
   22 |                 str += vec;
      |                 ~~~~^~~~~~
/nix/gcc-13.3.0/include/c++/13.3.0/bits/basic_string.h:1366:7: note: candidate: ‘std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::operator+=(const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]’
 1366 |       operator+=(const basic_string& __str)
      |       ^~~~~~~~
/nix/gcc-13.3.0/include/c++/13.3.0/bits/basic_string.h:1366:38: note:   no known conversion for argument 1 from ‘std::vector<std::__cxx11::basic_string<char> >’ to ‘const std::__cxx11::basic_string<char>&’
 1366 |       operator+=(const basic_string& __str)
      |                  ~~~~~~~~~~~~~~~~~~~~^~~~~
/nix/gcc-13.3.0/include/c++/13.3.0/bits/basic_string.h:1376:7: note: candidate: ‘std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::operator+=(const _CharT*) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]’
 1376 |       operator+=(const _CharT* __s)
      |       ^~~~~~~~
/nix/gcc-13.3.0/include/c++/13.3.0/bits/basic_string.h:1376:32: note:   no known conversion for argument 1 from ‘std::vector<std::__cxx11::basic_string<char> >’ to ‘const char*’
 1376 |       operator+=(const _CharT* __s)
      |                  ~~~~~~~~~~~~~~^~~
/nix/gcc-13.3.0/include/c++/13.3.0/bits/basic_string.h:1386:7: note: candidate: ‘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>]’
 1386 |       operator+=(_CharT __c)
      |       ^~~~~~~~
/nix/gcc-13.3.0/include/c++/13.3.0/bits/basic_string.h:1386:25: note:   no known conversion for argument 1 from ‘std::vector<std::__cxx11::basic_string<char> >’ to ‘char’
 1386 |       operator+=(_CharT __c)
      |                  ~~~~~~~^~~
/nix/gcc-13.3.0/include/c++/13.3.0/bits/basic_string.h:1400:7: note: candidate: ‘std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::operator+=(std::initializer_list<_Tp>) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]’
 1400 |       operator+=(initializer_list<_CharT> __l)
      |       ^~~~~~~~
/nix/gcc-13.3.0/include/c++/13.3.0/bits/basic_string.h:1400:43: note:   no known conversion for argument 1 from ‘std::vector<std::__cxx11::basic_string<char> >’ to ‘std::initializer_list<char>’
 1400 |       operator+=(initializer_list<_CharT> __l)
      |                  ~~~~~~~~~~~~~~~~~~~~~~~~~^~~
foo.cc:26:27: warning: comparison of integer expressions of different signedness: ‘int’ and ‘std::__cxx11::basic_string<char>::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]
   26 |         for (int i = 0; i < str.size(), i++){
      |                         ~~^~~~~~~~~~~~
foo.cc:26:27: warning: value computed is not used [-Wunused-value]
foo.cc:26:44: error: expected ‘;’ before ‘)’ token
   26 |         for (int i = 0; i < str.size(), i++){
      |                                            ^
      |                                            ;
foo.cc:27:28: warning: comparison with string literal results in unspecified behavior [-Waddress]
   27 |                 if (str[i] == "1"){
foo.cc:27:28: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]

信息

递交者
类型
递交
题目
P1848 记数问题
语言
C++
递交时间
2024-08-22 15:18:03
评测时间
2024-08-22 15:18:03
评测机
分数
0
总耗时
0ms
峰值内存
0 Bytes