treenef's code in the fourth post in this thread is functionally equivalent. I will assume that the difference is that you want to have my_string initialized first, followed by location later. The best way to do that depends on why you want to do that. In this simple example, there is no reason to do that, which is why treenef's code should be sufficient.
However, here are two C++ examples that assign the location after the my_string is initialized.
Code:
#include <iostream>
#include <string>
using namespace std;
int main()
{
string location;
string my_string1 = "The rain in ";
string my_string2 = " is falling on the plain";
location = "Spain";
cout<<my_string1 + location + my_string2;
return 0;
}
Code:
#include <iostream>
#include <string>
using namespace std;
int main()
{
string location;
string my_string = "The rain in is falling on the plain";
int insertLoc = 12;
location = "Spain";
my_string.insert(insertLoc, location);
cout<<my_string;
return 0;
}
There are other options as well.