带有覆盖无效器的方法没有使任何基础 class 方法无效
The method with the override invalidator did not invalidate any base class method
我正在使用 Visual Studio 2015 Enterprise 学习 Unreal Engine 4.13.2 和 C++。
我认为我的问题是 C++,所以我认为这里是询问它的最佳位置。
我有一个继承自 AActor class 的 C++ class。我必须重写 AActor 的一个方法,所以我把它放在我的头文件中:
virtual void ReceiveHit(class UPrimitiveComponent* MyComp, class AActor* Other, class UPrimitiveComponent* OtherComp, bool bSelfMoved, FVector HitLocation, FVector HitNormal, FVector NormalImpulse, const FHitResult& Hit);
而且我已经在cpp文件中实现了。
但是我得到以下编译器错误:
MyActor.h(23): error C3668: 'MyActor::ReceiveHit': The method with the
override invalidator did not invalidate any base class method
我从 AActor.h 文件中复制了 ReceiveHit
方法,但我收到了那个错误。
我还有另一种方法可以毫无问题地覆盖。这是 MyActor
头文件:
#pragma once
#include "GameFramework/Actor.h"
#include "MyActor.generated.h"
UCLASS()
class MYGAME_API AMyActor : public AActor
{
GENERATED_BODY()
public:
// Sets default values for this actor's properties
AMyActor();
// Called when the game starts or when spawned
virtual void BeginPlay() override;
// Called every frame
virtual void Tick( float DeltaSeconds ) override;
virtual void ReceiveHit(class UPrimitiveComponent* MyComp, AActor* Other, class UPrimitiveComponent* OtherComp, bool bSelfMoved, FVector HitLocation, FVector HitNormal, FVector NormalImpulse, const FHitResult& Hit) override;
private:
UProjectileMovementComponent* MyMovement;
};
我该如何解决这个错误?
问题是这不是虚方法。他们更改了 API,而我正在沿用一个旧示例。
不,我可以使用虚拟的 NotifyHit,我可以覆盖它:
virtual void NotifyHit
(
class UPrimitiveComponent * MyComp,
AActor * Other,
class UPrimitiveComponent * OtherComp,
bool bSelfMoved,
FVector HitLocation,
FVector HitNormal,
FVector NormalImpulse,
const FHitResult & Hit
)
我正在使用 Visual Studio 2015 Enterprise 学习 Unreal Engine 4.13.2 和 C++。
我认为我的问题是 C++,所以我认为这里是询问它的最佳位置。
我有一个继承自 AActor class 的 C++ class。我必须重写 AActor 的一个方法,所以我把它放在我的头文件中:
virtual void ReceiveHit(class UPrimitiveComponent* MyComp, class AActor* Other, class UPrimitiveComponent* OtherComp, bool bSelfMoved, FVector HitLocation, FVector HitNormal, FVector NormalImpulse, const FHitResult& Hit);
而且我已经在cpp文件中实现了。
但是我得到以下编译器错误:
MyActor.h(23): error C3668: 'MyActor::ReceiveHit': The method with the override invalidator did not invalidate any base class method
我从 AActor.h 文件中复制了 ReceiveHit
方法,但我收到了那个错误。
我还有另一种方法可以毫无问题地覆盖。这是 MyActor
头文件:
#pragma once
#include "GameFramework/Actor.h"
#include "MyActor.generated.h"
UCLASS()
class MYGAME_API AMyActor : public AActor
{
GENERATED_BODY()
public:
// Sets default values for this actor's properties
AMyActor();
// Called when the game starts or when spawned
virtual void BeginPlay() override;
// Called every frame
virtual void Tick( float DeltaSeconds ) override;
virtual void ReceiveHit(class UPrimitiveComponent* MyComp, AActor* Other, class UPrimitiveComponent* OtherComp, bool bSelfMoved, FVector HitLocation, FVector HitNormal, FVector NormalImpulse, const FHitResult& Hit) override;
private:
UProjectileMovementComponent* MyMovement;
};
我该如何解决这个错误?
问题是这不是虚方法。他们更改了 API,而我正在沿用一个旧示例。
不,我可以使用虚拟的 NotifyHit,我可以覆盖它:
virtual void NotifyHit
(
class UPrimitiveComponent * MyComp,
AActor * Other,
class UPrimitiveComponent * OtherComp,
bool bSelfMoved,
FVector HitLocation,
FVector HitNormal,
FVector NormalImpulse,
const FHitResult & Hit
)