Compile Error

/in/foo.cc: In function 'int main()':
/in/foo.cc:11:15: error: no matching function for call to 'std::__cxx11::basic_string<char>::erase(int&, std::__cxx11::string&)'
   s.erase(p,s1);
               ^
In file included from /usr/include/c++/6/string:52:0,
                 from /usr/include/c++/6/bits/locale_classes.h:40,
                 from /usr/include/c++/6/bits/ios_base.h:41,
                 from /usr/include/c++/6/ios:42,
                 from /usr/include/c++/6/istream:38,
                 from /usr/include/c++/6/sstream:38,
                 from /usr/include/c++/6/complex:45,
                 from /usr/include/c++/6/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/6/bits/stdc++.h:52,
                 from /in/foo.cc:1:
/usr/include/c++/6/bits/basic_string.h:1560:7: note: candidate: std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::erase(std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size_type, std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size_type) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size_type = long unsigned int]
       erase(size_type __pos = 0, size_type __n = npos)
       ^~~~~
/usr/include/c++/6/bits/basic_string.h:1560:7: note:   no known conversion for argument 2 from 'std::__cxx11::string {aka std::__cxx11::basic_string<char>}' to 'std::__cxx11::basic_string<char>::size_type {aka long unsigned int}'
/usr/include/c++/6/bits/basic_string.h:1576:7: note: candidate: std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::iterator std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::erase(std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::__const_iterator) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::iterator = __gnu_cxx::__normal_iterator<char*, std::__cxx11::basic_string<char> >; typename __gnu_cxx::__alloc_traits<typename __gnu_cxx::__alloc_traits<_Alloc>::rebind<_CharT>::other>::pointer = char*; std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::__const_iterator = __gnu_cxx::__normal_iterator<const char*, std::__cxx11::basic_string<char> >; typename __gnu_cxx::__alloc_traits<typename __gnu_cxx::__alloc_traits<_Alloc>::rebind<_CharT>::other>::const_pointer = const char*]
       erase(__const_iterator __position)
       ^~~~~
/usr/include/c++/6/bits/basic_string.h:1576:7: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/6/bits/basic_string.h:1595:7: note: candidate: std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::iterator std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::erase(std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::__const_iterator, std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::__const_iterator) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::iterator = __gnu_cxx::__normal_iterator<char*, std::__cxx11::basic_string<char> >; typename __gnu_cxx::__alloc_traits<typename __gnu_cxx::__alloc_traits<_Alloc>::rebind<_CharT>::other>::pointer = char*; std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::__const_iterator = __gnu_cxx::__normal_iterator<const char*, std::__cxx11::basic_string<char> >; typename __gnu_cxx::__alloc_traits<typename __gnu_cxx::__alloc_traits<_Alloc>::rebind<_CharT>::other>::const_pointer = const char*]
       erase(__const_iterator __first, __const_iterator __last)
       ^~~~~
/usr/include/c++/6/bits/basic_string.h:1595:7: note:   no known conversion for argument 1 from 'int' to 'std::__cxx11::basic_string<char>::__const_iterator {aka __gnu_cxx::__normal_iterator<const char*, std::__cxx11::basic_string<char> >}'
/in/foo.cc:13:5: error: request for member 'find' in 'p', which is of non-class type 'int'
   p.find(s1);
     ^~~~

信息

递交者
类型
递交
题目
P1980 1.7.21单词替换
语言
C++
递交时间
2024-07-23 09:49:00
评测时间
2024-07-23 09:49:00
评测机
分数
0
总耗时
0ms
峰值内存
0 Bytes