I don't how to description this puzzle, just like this:
int *fun_num()
{
int b = 123;
return &b;
}
char *fun_char()
{
char *b = "123";
return b;
}
int main(int argc, char *argv[])
{
int *pfun;
char *pchar;
pfun = fun_num();
pchar = fun_char();
cout << *pfun << endl;
cout << *fun_num() << endl;
cout << pchar << endl;
cout << fun_char() << endl;
}
//===============Result==============
4335768 // this is right to delete object "b"
123 // this is the return value
123 // why the object "b" isn't deleted? <---puzzle at here
123