[vtkusers] why are destructors protected?
Volpe, Christopher R (CRD)
volpecr at crd.ge.com
Fri Jun 1 16:17:40 EDT 2001
> Sorry if this is a dummy question, but...
No, not at all...
>
> I wonder why constructor, destructor, operator=, copy constructor, ...
> are *protected* in vtk classes?
> It is just to know.
To prevent people from using them to create static (file/global scope) and automatic (on the stack)
instances of objects. There are aspects of object/memory management (e.g. reference counting) that
depend on all instances existing on the heap only. Therefore, you have to use a class's New() method
to instantiate one of them, and the instance's Delete() method to destroy that instance.
Chris
More information about the vtkusers
mailing list