do I need to take care of memory allocation, scope and deletion about c++ "string" object?
for example:
#include <string>
const char* func3() {
string s = "this is a literal string";
return s.c_str();
}
string func2() {
string s = "this is a literal string";
return s;
}
const char* func1() {
const char* s = "this is a literal string";
return s;
}
void func() {
const char* s1 = func1();
string s2 = func2();
const char* s3 = func3();
delete s1; //?
delete s3; //?
}
func2: I don't need to 'delete' s2. func3: do I need to 'delete s3' ?
btw, is func1 correct? Is character memory content still available after it leaving func1 scope? If yes, should I delete it when I do not need it any more?