|
-
October 2nd, 2013, 08:24 AM
#2
Re: Regarding new operator.
 Originally Posted by srvolatile
What will happen, If I don't delete the allocated memory before calling Initialise() in Drawing() method ?
You will have a memory leak.
 Originally Posted by srvolatile
Is it a good idea to delete the memory and re allocate with a new operator?
In that order, no, because it is not exception safe. If the allocation or object creation fails, you cannot restore the object that you just deleted.
Whether the approach of creating a new object and deleting the old one is better than reusing the same object depends on the use case. You didn't provide enough details to say anything specific.
Cheers, D Drmmr
Please put [code][/code] tags around your code to preserve indentation and make it more readable.
As long as man ascribes to himself what is merely a posibility, he will not work for the attainment of it. - P. D. Ouspensky
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|