So I have this function:
char * func()
{
char * temp = new char[length]; // Length is defined elsewhere
/*
Do some stuff with temp
*/
return temp
}
My problem is I'm not sure whether or not this leaks memory. If so, I don't know how to make it not do that. I thought I could delete it after return, but how would I do that? (Also assuming i can't just delete it outside the function) This function is part of a class. This function's purpose is to return an internal value of the class. A user would use this function. i find it too much to ask that the user deletes the value afterwards. Thanks!