MyInterface.h
UINTERFACE(MinimalAPI)
class UMyInterface : public UInterface
{
GENERATED_BODY()
};
class INTERFACETEST_API IMyInterface
{
GENERATED_BODY()
// Add interface functions to this class. This is the class that will be inherited to implement this interface.
public:
UFUNCTION(BlueprintCallable, BlueprintImplementableEvent)
bool Add(AActor* item);
};
MyActorComponent.h
#include "CoreMinimal.h"
#include "MyInterface.h"
#include "Components/ActorComponent.h"
#include "MyActorComponent.generated.h"
UCLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) )
class INTERFACETEST_API UMyActorComponent : public UActorComponent, public IMyInterface
{
GENERATED_BODY()
public:
// Sets default values for this component's properties
UMyActorComponent();
UFUNCTION(BlueprintCallable, BlueprintImplementableEvent)
bool Add(AActor* item);
virtual bool Add_Implementation(AActor* item) override;
protected:
// Called when the game starts
virtual void BeginPlay() override;
public:
// Called every frame
virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override;
};
MyActorComponent.cpp
bool UMyActorComponent::Add_Implementation(AActor * item)
{
return false;
}
error C3668: ‘UMyActorComponent::Add_Implementation’: method with override specifier ‘override’ did not override any base class methods
What’s wrong?