Re: [Dev-C++] How would you write a method returning a string ?
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Jamiil A. <jal...@gm...> - 2007-07-22 23:56:13
|
And how would you suggest one should write a method that receives a 'const
char*' and returns a 'std::string&'?
----- Original Message -----
From: "matheus ribeiro" <mfr...@gm...>
To: <dev...@li...>
Sent: Sunday, July 22, 2007 8:45 AM
Subject: Re: [Dev-C++] How would you write a method returning a string ?
>> std::string& NameSpace::ClassName::MethodName(const char* var){return
>> someString = var;}
>
>
> Not a good idea if somestring is a function variable. It will go out
> of scope and be destroyed, returning a ref to it will yield undefined
> results.
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by: Splunk Inc.
> Still grepping through log files to find problems? Stop.
> Now Search log events and configuration files using AJAX and a browser.
> Download your FREE copy of Splunk now >> http://get.splunk.com/
> _______________________________________________
> Dev-cpp-users mailing list
> Dev...@li...
> TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm
> https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
|