Return by copy
I am having difficulty understanding how this situation will work.
Code:
using std::string;
//Prototypes
string MixCase(string& sString);
void UseRef (string& sRefString);
void UseCopy(string sCopyString);
void main(int argc, char** argv)
{
string MyString;
UseRef (MixCase(MyString));
UseCopy(MixCase(MyString));
}
string MixCase(string& sString)
{
string sTempString;
...
return sTempString;
}
string UseRef(string& sRefString)
{
//Will sRefString be valid when it comes from MixCase ?????
}
string UseCopy(string sCopyString)
{
//This should work just fine
}
I am trying to convert Delphi (pascal) code to C++. The Delphi code that I am converting does this type of stuff all the time.
Any comments are welcome.
Thanks in advance.
Kendall
John 3:16
For God so loved the world ...