Event handling error C++

Hello everyone!

I am currently working on a game using C++ as the primary way to control the different aspect of my game, but I am running into a lot of errors when it comes to handle events: I had a look at [ the wiki page concerning events handling][1] , and other snippets of code that come from various tutorial.

I can also do it in Blueprint but I want to know why my C++ solution is not working , here is a screen of my BP, the part circled in red is what I want to reproduce trough the code :

Here is the code I tried to use without success:

//foo.h

class Afoo : public ADestructibleActor
{
GENERATED_UCLASS_BODY()

UFUNCTION()
void OnDestruction(float Damage, class UDamageType * DamageType, class AController * InstigatedBy, class AActor* DamageCauser);


}

//foo.cpp

Afoo::Afoo(const class FPostConstructInitializeProperties& PCIP)
	: Super(PCIP)
{	
 OnTakeAnyDamage.AddDynamic(this, &Afoo::OnDestruction);
}

void Afoo:OnDestruction(float Damage, class UDamageType * DamageType, class AController * InstigatedBy, class AActor* DamageCauser)
{
 if (GEngine)
	{
		GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Blue, FString::Printf(TEXT("Custom Function Called")));

	}
}

The error message I have is :
error C2664: ‘void TBaseDynamicMulticastDelegate_FourParams::__Internal_AddDynamic(UserClass ,void (__cdecl ATarget:: )(Param1Type,Param2Type,Param3Type,Param4Type),const FString &)’ : cannot convert argument 2 from ‘void (__cdecl ATarget::* )(float,UDamageType *,AController *,AActor )’ to 'void (__cdecl ATarget:: )(Param1Type,Param2Type,Param3Type,Param4Type)’
with

     [
          UserClass=ATarget
,            Param1Type=float
,            Param2Type=const UDamageType *
,            Param3Type=AController *
,            Param4Type=AActor *
      ]

      and

      [
          Param1Type=float
,            Param2Type=const UDamageType *
,            Param3Type=AController *
,            Param4Type=AActor *
      ]

     Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast

If I try to add the delegate in foo.h ,

DECLARE_DYNAMIC_MULTICAST_DELEGATE_FourParams(FTakeAnyDamageSignature, float, Damage, class UDamageType * ,DamageType, class AController * ,InstigatedBy, class AActor*, DamageCauser);

like it is explained in the wiki got this error message :

Can’t override delegate signature function ‘TakeAnyDamageSignature_DelegateSignature’

Cheers,

DECLARE_DYNAMIC_MULTICAST_DELEGATE_FourParams( FTakeAnyDamageSignature, float, Damage, const class UDamageType*, DamageType, class AController*, InstigatedBy, class AActor*, DamageCauser );

Here the FTakeAnyDamageSignature already declare so you can not override, and for the first error your OnDestruction mus be like this:

void OnDestruction(float Damage, const class UDamageType * DamageType, class AController * InstigatedBy, class AActor* DamageCauser);

It’s const class UDamageType* not class UDamageType*

■■■■ I missed that, but why it is changing from the FTakeAnyDamageSignature that is provided in the official documentation ?