Problem description:
It is needed in C to delete the allocated memory for a pointer to an array
char * (how we can define string in C).
My question:
I am wondering if it is also necessary for C++ string types.
For example:
Let's say I have a function which is responsible for converting all uppercase characters to lowercase like below.
string convertToLowerCase(string str) {
string res = str;
for (int i=0; i<str.length();++i) {
res[i]= tolower(str[i]);
}
return res;
}
- After calling this function for comparing two strings, I do not need
to de-allocate the return string variable of the
convertToLowerCasefunction on the caller side. - My understanding is that the memory de-allocation is done in C++ string type.
- Please correct me if I am wrong.