A: Yes, except possibly encapsulated inside the implementations of low-level data structures.
The more general question on SO was:
About the usage of new and delete, and Stroustrup's advice
About the usage of
new
anddelete
, and Stroustrup's advice...He says something like (but not exactly, this is from my notes of his book):
A rule of thumb is that,
new
belongs in constructors and similar operations,delete
belongs in destructors. In addition,new
is often used in arguments to resource handles. Otherwise avoid usingnew
anddelete
, use resource handles (smart pointers) instead.I was wondering if the more experienced folks with C++11 have really applied this or not.
My impression of this was, wow this seems like a really cool rule to follow. But then I got suspicious, as for any general rule. At the end of the day you will end up using
new
anddelete
wherever necessary. But maybe this rule is a good guideline I don't know.
Add a Comment
Comments are closed.