Returning a wxString object

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
spflanze
Earned some good credits
Earned some good credits
Posts: 130
Joined: Tue Feb 15, 2011 10:02 pm

Returning a wxString object

Post by spflanze »

I need to overload wxToString() for use in wxConfigBase::Write() . Here is a sample of how I would do this:

Code: Select all

wxString wxToString( tFileConfigArray A )
{ wxString ret;
  return ret;
}
I am concerned about returning a local wxString object. What will happen to the returned wxString object when it is instantiated in the stack?
User avatar
doublemax
Moderator
Moderator
Posts: 19160
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Returning a wxString object

Post by doublemax »

That's safe, the wxString will be copied.

It's only a problem when you return references or pointers to local variables.
Use the source, Luke!
Post Reply