我正在尝试将用户输入的名称插入到预先存在的字符串中,但我不断收到一条错误消息:
“[Error] no matching function for call to 'std::basic_string::insert(std::basic_string::iterator, std::string&)'”在第 25 行
代码:
#include <iostream>
#include <string>
using namespace std;
string custName = " ";
string firstName = " ";
string midInitial = " ";
string lastName = " ";
string getFullName = "";
string comma = ",";
int getName()
{
cout<<"Please enter your first name \n";
cin>>firstName;
cout<<"Please enter your middle initial \n";
cin>>midInitial;
cout<<"Please enter your surname \n";
cin>>lastName;
getFullName = firstName+" "+midInitial+". "+lastName;
}
int addName()
{
custName.insert (custName.end(), ',');
custName.insert(custName.end(), getFullName);
}
int main ()
{
getName();
custName = getFullName;
getName();
addName();
getName();
addName();
getName();
addName();
cout<<custName
}