string pointer pp
is temporary, why is it still correct to cout the c_str after I delete the pointer?
#include <string>
#include <iostream>
using namespace std;
int main(){
const char* tt = NULL;
{
string * pp = new string("big");
tt = pp->c_str();
cout << "tt->pp:\t" << tt << endl;
delete pp;
}
cout << tt << endl;
return 0;
}
The output is:
tt->pp: big
big