记录详情

Compile Error

foo.cc: In function 'int main()':
foo.cc:8:13: error: conflicting declaration 'int a'
    8 |         int a,b;cin>>a>>b;
      |             ^
foo.cc:7:16: note: previous declaration as 'std::string a'
    7 |         string a;
      |                ^
foo.cc:9:24: error: cannot convert 'std::string' {aka 'std::__cxx11::basic_string<char>'} to 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'}
    9 |         cout<<a.substr(a,b);
      |                        ^
      |                        |
      |                        std::string {aka std::__cxx11::basic_string<char>}
In file included from /nix/gcc-13.2.0/include/c++/13.2.0/string:54,
                 from /nix/gcc-13.2.0/include/c++/13.2.0/bitset:52,
                 from stdc++.h:52:
/nix/gcc-13.2.0/include/c++/13.2.0/bits/basic_string.h:3151:24: note:   initializing argument 1 of 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::substr(size_type, size_type) const [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; size_type = long unsigned int]'
 3151 |       substr(size_type __pos = 0, size_type __n = npos) const
      |              ~~~~~~~~~~^~~~~~~~~
正在同步测试数据,请稍后

信息

递交者
类型
递交
题目
P1052 A8-7 删除字符串中一个子串
语言
C++
递交时间
2024-03-21 14:11:20
评测时间
2024-03-21 14:11:20
评测机
分数
0
总耗时
0ms
峰值内存
0 Bytes