O'Reilly logo

C++ Common Knowledge: Essential Intermediate Programming by Stephen C. Dewhurst

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required