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

3

I have the following code:

#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();
};

尽管我按照教程操作,但每次在vtkStandardNewMacro(InteractorStyle);处始终出现以下错误:

error C4430:缺少类型说明符 - 假定为int。注意:C ++不支持默认int。

如何解决这个问题?


这个错误可能意味着您缺少一些头文件。 - AMA
2
@AMA 谢谢。我需要添加 #include <vtkObjectFactory.h> - Bla...
1个回答

7
你只需要添加 #include <vtkObjectFactory.h>。很遗憾,这个教程从未明确提到过这一点。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接