我对 C++ 很陌生,并且一直在玩弄它一段时间。如果对这些错误有任何见解,我将不胜感激。以下程序应产生以下结果:
#include <iostream>
#include <string>
using namespace std;
string Cut(string &strString, int nStart, int nLength)
{
string strCopy;
strString.copy(strCopy, nLength, nStart);
strString.erase(nStart, nLength);
return strCopy;
}
int main()
{
string strHate = "I hate tuna.";
cout << strHate << endl;
string strTuna;
strTuna = Cut(strHate, 8, 4);
cout << strHate << endl;
cout << strTuna << endl;
}
应该产生
I hate tuna.
I hate .
tuna
但是,相反,我收到此错误消息:
9|error: no matching function for call to 'std::basic_string<char>::copy(std::string&, int&, int&)'
非常感激,
窃贼