I have a class with a function that returns a copy of a private member:
class MyClass
{
MyString str;
public:
MyString getStr() { return str; }
}
Another function, func, takes in a const &MyString that is bound to a statement handle. When I invoke func(o.getStr()), the copy object returned by getStr goes out of scope after the func call and is no longer valid for the statement handle. I can create a local variable MyString ms = o.getStr() and then pass that to func, but I don't want to have to do that multiple times for different getters. Also, func needs to take in a ref since sometimes I need to pass in a local variable and change the value of it after subsequent uses of the statement handle. Is there a good solution to this?