Home > Back-end >  C consult...
C consult...

Time:10-13

Class A
{
Public:
int a;
};

A * f ()
{
A * t=new A;
Return t;
}

Int _tmain (int arg c, _TCHAR * argv [])
{
A * b;
B=f ();
The delete b;
return 0;
}
Everyone a great god this program has a problem?
T need to release the object? How to release? Thanks

CodePudding user response:

T don't release, because b=f (); B==t, after the delete or delete the t b

CodePudding user response:

Who follows a principle: open up, who released, a new one for delete

CodePudding user response:

You so that you can, because the t and b point to the same address,

CodePudding user response:

Pointer to the memory is released is ok
  • Related