c++ - What does *New() mean when declaring member function? -
i'm working on vtk program , have found class (specifically one: image region) need incorporate code. have made separate imageregion.h , imageregion.cpp files can included in project. problem here
static vtkbordercallback *new()
function not know how implement in .cpp file or, quite honest, purpose serves @ all. do? necessary have it?
when compiling error:
/home/desktop/test/src/imageregion.cpp:7:10: error: ‘vtkbordercallback::vtkbordercallback’ names constructor, not type
my .h file:
//imageregion.h #pragma once #include <vtksmartpointer.h> #include <vtkactor.h> #include <vtkassemblynode.h> #include <vtkassemblypath.h> #include <vtkborderrepresentation.h> #include <vtkcommand.h> #include <vtkcoordinate.h> #include <vtkimagemapper3d.h> #include <vtkimageactor.h> #include <vtkinteractorstyleimage.h> #include <vtkpolydata.h> #include <vtkproppicker.h> #include <vtkproperty2d.h> #include <vtkborderwidget.h> #include <vtkrenderwindow.h> #include <vtkrenderwindowinteractor.h> #include <vtkrenderer.h> class vtkbordercallback : public vtkcommand { public: vtkbordercallback(); static vtkbordercallback *new(); virtual void execute(vtkobject *caller, unsigned long, void*); void setrenderer(vtksmartpointer<vtkrenderer> ren); void setimageactor(vtksmartpointer<vtkimageactor> im); double coords[6]; private: vtksmartpointer<vtkrenderer> renderer; vtksmartpointer<vtkimageactor> imageactor; };
and .cpp file:
//imageregion.cpp #include "imageregion.h" vtkbordercallback::vtkbordercallback(){} static vtkbordercallback::vtkbordercallback* new() { return new vtkbordercallback; } void vtkbordercallback::execute(vtkobject *caller, unsigned long, void*) { //do stuff, original vtk example code } void vtkbordercallback::setrenderer(vtksmartpointer<vtkrenderer> ren) {this->renderer = ren;} void vtkbordercallback::setimageactor(vtksmartpointer<vtkimageactor> im) {this->imageactor = im;}
any appreciated.
this
static vtkbordercallback *new();
is static
member function called new
, taking no arguments, , returning pointer vtkbordercallback
.
in implementation, should omit static
. need place function in scope of class:
vtkbordercallback* vtkbordercallback::new() {// ^^^^^^^^^^^^^^^^^^^ return new vtkbordercallback; // danger! caller needs delete }
Comments
Post a Comment