Here is a function:
void foo() { string str = \"StackOverflo\"; str.push_back(\'w\'); }
When we declare the string inside the function, i
all local variables in C++ are stores in Stack. even local pointers are stored in Stack. but the memory allocated in pointer are stored on Heap.
So, your str is stored in Stack while its value is stored in Heap. because std::string uses char pointer to allocate your "stackoverflow"
str
std::string
char
"stackoverflow"