[vtkusers] Using vtkDenseArray as a member variable

David Doria daviddoria+vtk at gmail.com
Fri Nov 13 10:22:18 EST 2009


Ah fantastic. I guess I always assume I'm doing something wrong with
VTK but I guess sometimes it's just c++.

This answers another of my long standing questions about why I could
never forward declare vtkSmartPointer.

Thanks Jeff.

David



On Fri, Nov 13, 2009 at 10:17 AM, Jeff Baumes <jeff.baumes at kitware.com> wrote:
>> If I indeed declare a pointer as the member variable
>>
>> class vtkDenseArray;
>> class vtkMyClass : public vtkPolyDataAlgorithm
>> {
>> ...
>> private:
>>  vtkDenseArray<double>* OutputGrid;
>> };
>>
>> and initialize the object in the constructor in the implementation file:
>>
>> #include "vtkDenseArray.h"
>> ...
>> vtkMyClass::vtkMyClass()
>> {
>>  this->OutputGrid = vtkDenseArray<double>::New();
>> }
>>
>> The errors are:
>> error: 'vtkDenseArray' is not a template
>> and
>> error: template argument required for 'class vtkDenseArray'
>
> Here you need to correctly forward declare a template class. Some
> googling found that this should work:
>
> template <typename T> class vtkDenseArray;
>
> Jeff
>



More information about the vtkusers mailing list