O'Reilly logo

Getting Started With JUCE by Martin Robinson

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

Employing smart pointer classes

The OwnedArray class may be considered a manager of smart pointers, in the sense that it manages the lifetime of the object to which it points. JUCE includes a range of other smart pointer types to help solve a number of common issues when writing code using pointers. In particular, these help avoid mismanagement of memory and other resources.

Perhaps the simplest smart pointer is implemented by the ScopedPointer class. This manages a single pointer and deletes the object to which it points when no longer needed. This may happen in two ways:

  • When the ScopedPointer object itself is destroyed
  • When a new pointer is assigned to the ScopedPointer object

One use of the ScopedPointer class is as an alternative means of storing ...

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