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: matheus r. <mfr...@gm...> - 2007-07-23 00:26:00
|
The first question to ask is: why would one need that? C++ strings
were made thinking of them as a base value, like int.
Id rather write a function with
const std::string somefunction(const char *val)
prototype.
2007/7/22, Jamiil Abduqadir <jal...@gm...>:
> 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
>
>
> -------------------------------------------------------------------------
> 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
>
|