Salve, voleco fare qualche domanda per verificare di aver capito bene.
Prima domanda:
string a = "ciao";
la variabile a si trova nello stack, l'oggetto string "ciao" si trova nello stack. Vero?
Seconda domanda:
string* b = new string ("albero");
la variabile b si trova nello stack, l'oggetto string "albero" si trova nell'heap. Vero?
Terza domanda:
in un libro da cui sto studiando il C++, vi è questo esempio:
Employee harry;
Employee* p = &harry;
However, you should never delete an address that you obtained in this way.
delete &harry; // ERROR!
Doing so would add a block of stack memory to memory that is managed by the heap. Later,
that block of memory could be simultaneously allocated to a stack and a heap object. Mutating
one of them would corrupt the other.
Anche tradotta in italiano, non capisco la frase che ho sottolineato.Mi aiutate a capire? nei dettagli perfavore