本文介绍了vtkStandardNewMacro给出错误C4430:缺少类型说明符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下代码:

#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); 的错误:

Even though I follow the tutorial, it always gives me below error for vtkStandardNewMacro(InteractorStyle); :

该如何解决?

推荐答案

您需要添加的只是 #include< vtkObjectFactory.h> .该教程从未明确提及过这一点,太糟糕了.

All you need to add is #include <vtkObjectFactory.h>. The tutorial never explicitly mentioned this, too bad.

这篇关于vtkStandardNewMacro给出错误C4430:缺少类型说明符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-02 04:57