[vtkusers] Returning a smart pointer

Anja Ende anja.ende at googlemail.com
Fri Nov 6 06:26:39 EST 2009


Hello,

A quick question about returning a smart pointer from class functions.
Is this the correct ussage?

class SomeClass
{
   vtkPolayData * SomeMethod()
   {
      vtkSmartPointer<vtkPolyData> myData = vtkSmartPointer<vtkPolyData>::New();
      ....
      return myData;
   }
}

In the caller:

vtkPolyData * data = instance.SomeMethod();

Would this work? Or am I better off with using class members and
deleting them in the destructor when I want to pass data around?

Thanks,

Anja



More information about the vtkusers mailing list