简体   繁体   English

如何修复虚幻引擎 4 中的“不允许指向不完整类类型的指针”错误

[英]How to fix "Pointer to Incomplete class type is not allowed" error in Unreal Engine 4

I'm trying to learn C++ using a book called "Learning C++ by Creating Games with Unreal Engine 4" by Sharan Volin.我正在尝试使用 Sharan Volin 的一本名为“通过使用虚幻引擎 4 创建游戏来学习 C++”的书来学习 C++。 Up to this point, I had been following the examples, but I got stuck at this error, despite the fact that I'm typing everything verbatim from the text.到目前为止,我一直在关注这些例子,但我被这个错误困住了,尽管我正在逐字输入文本中的所有内容。 Is there something I am missing or not understanding?有什么我遗漏或不理解的吗?

I've tried to see if there were any other guides or Git Repos on this exercise, but had no luck.我试图看看这个练习是否有任何其他指南或 Git Repos,但没有运气。 Other Stack user questions regarding error code E0393 (the error I'm getting) don't seem to help, as I have the Avatar.h file included in the Avatar.cpp file.关于错误代码 E0393(我得到的错误)的其他 Stack 用户问题似乎没有帮助,因为Avatar.h文件中包含Avatar.cpp文件。

This is the code in the segment in the Avatar.cpp file giving me an error, specifically the last two lines that start as PlayerInputComponent->这是Avatar.cpp文件中段中的Avatar.cpp给我一个错误,特别是最后两行以PlayerInputComponent->开头

// Called to bind functionality to input
void AAvatar::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent)
{
Super::SetupPlayerInputComponent(PlayerInputComponent);
check(PlayerInputComponent);
PlayerInputComponent->BindAxis("Forward", this, &AAvatar::MoveForward);
PlayerInputComponent->BindAxis("Strafe", this, &AAvatar::MoveRight);
}

This is some of the code present in the Avatar.h file, with only the last 4 lines being what I was instructed to type in.这是Avatar.h文件中的一些代码,只有最后 4 行是我被指示输入的内容。

public: 
    // Called every frame
    virtual void Tick(float DeltaTime) override;

    // Called to bind functionality to input
    virtual void SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) override;

    //New! These 2 new member function declarations
    //they will be used to move our player around!
    void MoveForward(float amount);
    void MoveRight(float amount);
};

The final result should allow me to move an avatar in the Unreal Project forward and to the right upon pressing "W" and "D" respectively.最终结果应该允许我在分别按下“W”和“D”后将虚幻项目中的化身向前和向右移动。 However, in the Avatar.cpp file, I get the error E0393 pointer to incomplete class type is not allowed .但是,在Avatar.cpp文件中,我收到错误E0393 pointer to incomplete class type is not allowed I also never get the project to launch in the Unreal Editor.我也从未让项目在虚幻编辑器中启动。

只需转到头文件“Avatar.h”并键入#include“Components/InputComponent.h”

In your cpp file as you have forward declared the class.在您的 cpp 文件中,您已经向前声明了该类。 You need to have the include for the actual definition in the .cpp file.您需要在 .cpp 文件中包含实际定义的包含。 So you need to have the include for the UInputComponent.所以你需要包含 UInputComponent。

On the docs for the Component: here you will see at the bottom of the page it's location in the engines files.在组件的文档上: 在这里您将在页面底部看到它在引擎文件中的位置。

#include "Runtime/Engine/Classes/Components/InputComponent.h"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 虚幻引擎4.18.0,Vs2017,不允许指向不完整类类型的错误指针 - unreal engine 4.18.0, Vs2017, Error pointer to incomplete class type is not allowed 错误:不允许指向不完整类类型的指针 - error: pointer to incomplete class type is not allowed “不允许指向不完整 class 类型的指针” - "Pointer to incomplete class type is not allowed" 指向不完整 class 类型的指针是不允许的 - Pointer to incomplete class type is not allowed 错误:不允许指向不完整类类型的指针。 SDL / c ++ - Error: Pointer to incomplete class type is not allowed. SDL/c++ 错误:不允许指向不完整类类型的指针。我该怎么做? - Error: Pointer to incomplete class type is not allowed. How do I go about this? 不允许不完整的类型(指针) - Incomplete type is not allowed (pointer) 具有类类型向量的前向声明-不允许指向不完整类类型的指针 - forward declaration with vector of class type - pointer to incomplete class type not allowed 部分模板类中不允许使用指向不完整类类型的指针 - pointer to incomplete class type is not allowed in a partial template class 引用自定义库中的对象会出现错误:“不允许指向不完整的类类型的指针” - Referring to an object from custom library gives error: "pointer to incomplete class type is not allowed"
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM