Item 42. Smart Pointers
We C++ programmers are a loyal bunch. Whenever we’re faced with a situation that requires a feature the language doesn’t support, we don’t abandon C++ to flirt with some other language; we just extend C++ to support the feature in which we’re interested.
For instance, it’s often the case that you’ll need something that behaves like a pointer, but a built-in pointer type just doesn’t do the job. In those cases, a C++ programmer will use a “smart pointer.” (See also Function Objects [18, 63] for similar observations about function pointers.)
A smart pointer is a class type that is tricked up to look and act like a pointer but that provides additional capability beyond that provided by a built-in pointer. Generally, a smart ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access