[Insight-users] Question concerning destructors

Ofri Sadowsky ofri@cs.jhu.edu
Mon, 25 Nov 2002 17:35:25 -0500


Hello,

What is the way to dispose of an itk object inheriting itk::Object?

In the normal case, itk::Object is instantiated using the New() method,
which somtimes returns a MyClass::Pointer and sometimes a MyClass * .
Then, for some classes, for example itk::Mesh, the destructor is
declared protected. It is not so for itk::VectorContainer. But then,
I tried to delete a VectorContainer, and got a runtime error.

Is the Pointer object returned from New() smart enough to release the
memory when it's destroyed, or when a reference count reaches zero? What
about classes which have not declared the Pointer type?

Thanks,

Ofri.