c++ - Exception handling before deleting dynamic memory in a function -


i allocated dynamic memory , clearing memory @ end of function using delete operator. have exception handling before delete. how can avoid memory leak in situation.

use std::unique_ptr or similar hold heap-allocated memory. deallocated automatically when smart pointer goes out of scope, whether or not exception thrown.


Comments

Popular posts from this blog

c++ - CryptStringToBinary API behavior -

java.util.scanner - How to read and add only numbers to array from a text file -

iphone - Three second countdown in cocos2d -