c++ resource allocation new statement

Perform every resource allocation (e.g., new) in its own code statement which immediately gives the new resource to a manager object (e.g., auto_ptr).

This guideline is easy to understand and remember, it neatly avoids all of the exception safety problems in the original problem, and by mandating the use of manager objects it helps to avoid many other exception safety problems as well. This guideline is a good candidate for inclusion in your team's coding standards

link http://www.gotw.ca/gotw/056.htm

file I/O http://www.zwqxin.com/archives/cpp/use-sstream.html

你可能感兴趣的:(c++ resource allocation new statement)