A
andylcx
hi all:
I have a code like below, is there any serious memory leakage in my
code. I am confusion now but no idea how to fix it. In the member
function of class A, I create a new object of class B like below:
void A::function()
{
B *newobject = new B;
newobject->....;
newobject->....; //did some action here
...
}
But I did not delete newobject in the A::function(acctually, I cannot
delete it since I need to use it later. Will the newobject be
automatically destroy when the main function end? Is the memory leakage
problem serious in this case? Thanks a lot!
I have a code like below, is there any serious memory leakage in my
code. I am confusion now but no idea how to fix it. In the member
function of class A, I create a new object of class B like below:
void A::function()
{
B *newobject = new B;
newobject->....;
newobject->....; //did some action here
...
}
But I did not delete newobject in the A::function(acctually, I cannot
delete it since I need to use it later. Will the newobject be
automatically destroy when the main function end? Is the memory leakage
problem serious in this case? Thanks a lot!