vtkStandardNewMacro 给出错误 C4430:缺少类型说明符

vtkStandardNewMacro gives error C4430: missing type specifier

我有以下代码:

#include <vtkInteractorStyleTrackballCamera.h>

class InteractorStyle : public vtkInteractorStyleTrackballCamera
{
    public:
        static InteractorStyle* New() {};
        vtkTypeMacro(InteractorStyle, vtkInteractorStyleTrackballCamera);
        InteractorStyle() {
            cout << "test";
        }
        virtual void OnLeftButtonDown();

        virtual void OnKeyPress();

    private:

};
vtkStandardNewMacro(InteractorStyle); //error here

void InteractorStyle::OnLeftButtonDown()
{
    std::cout << "test";
    // Forward events
    vtkInteractorStyleTrackballCamera::OnLeftButtonDown();
};
void InteractorStyle::OnKeyPress()
{
    // Get the keypress
    vtkRenderWindowInteractor *rwi = this->Interactor;
    std::string key = rwi->GetKeySym();

    // Output the key that was pressed
    std::cout << "Pressed " << key << std::endl;
    // Forward events
    vtkInteractorStyleTrackballCamera::OnKeyPress();
};

即使我遵循 tutorial,它总是给我以下 vtkStandardNewMacro(InteractorStyle); 的错误:

error C4430: missing type specifier - int assumed. Note: C++ does not support default-int

如何解决这个问题?

您只需添加 #include <vtkObjectFactory.h>。教程没有明确提到这一点,太糟糕了。