I am trying to understand reference.
So given the following program...
void Foo(std::string& m)
{
std::string f = "Foo Stack Content";
m = f;
}
int main()
{
std::string m = "Main Stack Content";
Foo(m);
std::cout << m << std::endl;
}
Since m is assigned f in Foo, and f is created on the stack in Foo, when Foo exits, f and the memory it points to won't be valid anymore. Does that mean that m is also invalid now?