It's the same situation as:
Code:
int func1()
{
return 1; //Returning 1 by value
}
std::string func2()
{
return std::string("Some String"); //Return a copy of std::string("Some String")
}
You're just returning a value. The problem is, as laserlight mentioned, when you try returning a reference or pointer:
Code:
int& func1()
{
int localVariable;
return localVariable; //localVariable won't exist after func1() ends
}
std::string* func2()
{
std::string localString("Some String");
return &localString; //This address will point to nothing when func2() ends
}