として格納されている文字列がありtempP
、C++ の経験がないためです。文字列に単語を追加する方法を考えていました。たとえば、C# では次のようになります。
tempP = tempP + "addtext";
それはあなたが期待したとおりです:
#include <iostream>
#include <string>
int main()
{
std::string tempP("temp");
tempP += "addText"; // the same as tempP = tempP + "addtext";
std::cout << tempP << std::endl;
return 0;
}
出力:tempaddText
std:string temp("something");
temp = temp + "addtext";
今tempはsomethingaddtextです。