0On Mon, 14 Jul 2003 10:27:52 GMT,
al***@start.no (Alf P. Steinbach) wrote:
On Mon, 14 Jul 2003 12:19:34 +0200, "orion30" <or*****@ifrance.com> wrote:
I would like to know, if an allocated variable returning by a fuction is
unallocated automatically ?
No.
If no how to proceed ?
Use smart-pointers. Use std::auto_ptr for simple
transfer of ownership (deallocation responsibility).
Use boost::shared_ptr for a pointer that isn't
necessarily "owned" by a single something.
std::auto_ptr lives in standard header <memory>.
boost::shared_ptr: go to [http://www.boost.org].
In my case, I want to return aa. After the call of polit, is aa is
unallocated automatically ?
char * polit(char *expressions)
{
.
.
.
aa = (char *)malloc(strlen(Result)*sizeof(char)+1);
Should be
aa = new char[ strlen(Result) + 1];
in C++.
return(aa);
}
Sorry, I didn't think. You're probably trying to achieve something
else than the code indicates. In that case, use std::string.