Here is a function:
void foo() {
string str = \"StackOverflo\";
str.push_back(\'w\');
}
When we declare the string inside the function, i
When we declare the String inside the function, is it stored on the Stack or Heap?
The string object itself is stored on the stack but it points to memory that is on the heap.
Why?
The language is defined such that the string object is stored on the stack. string's implementation to construct an object uses memory on the heap.