[vtkusers] Using vtkSmartPointer with my own classes
Vinicius Rogério Araujo Silva
vinicius.ras at gmail.com
Wed Dec 22 20:10:07 EST 2010
Hello all,
I've created a simple class, which is a subclass of vtkObject, and tried to
use vtkSmartPointer with it. The class is as follows:
class MyClass : public vtkObject
{
public:
MyClass()
{
std::cout << "BEING CONSTRUCTED" << std::endl;
}
~MyClass()
{
std::cout << "BEING DESTRUCTED" << std::endl;
}
};
And I'm trying to create a smart pointer for it like this:
vtkSmartPointer<MyClass> myPtr = vtkSmartPointer<MyClass>::New();
But the instantiation of the object/smartptr generates compiler errors.
Can anyone help me with that?
Compiling under Visual C++ 2008, my build log follows:
1>------ Build started: Project: TesteVTK, Configuration: Debug Win32 ------
1>Compiling...
1>TesteVTK.cpp
1>c:\users\vinicius\desktop\labmint\vtk\vtk-5.6.0\common\vtksmartpointer.h(113)
: error C2665: 'vtkSmartPointer<T>::vtkSmartPointer' : none of the 4
overloads could convert all the argument types
1> with
1> [
1> T=MyClass
1> ]
1>
c:\users\vinicius\desktop\labmint\vtk\vtk-5.6.0\common\vtksmartpointer.h(163):
could be 'vtkSmartPointer<T>::vtkSmartPointer(T *,const
vtkSmartPointerBase::NoReference &)'
1> with
1> [
1> T=MyClass
1> ]
1> while trying to match the argument list '(vtkObject *,
vtkSmartPointerBase::NoReference)'
1>
c:\users\vinicius\desktop\labmint\vtk\vtk-5.6.0\common\vtksmartpointer.h(112)
: while compiling class template member function 'vtkSmartPointer<T>
vtkSmartPointer<T>::New(void)'
1> with
1> [
1> T=MyClass
1> ]
1> c:\users\vinicius\documents\my
dropbox\projetos\testevtk\testevtk.cpp(70) : see reference to class template
instantiation 'vtkSmartPointer<T>' being compiled
1> with
1> [
1> T=MyClass
1> ]
1>Build log was saved at "file://c:\Users\Vinicius\Documents\Visual Studio
2008\Projects\TesteVTK\TesteVTK\Debug\BuildLog.htm"
1>TesteVTK - 1 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Thanks in advance.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20101222/e3b5e790/attachment.htm>
More information about the vtkusers
mailing list