Delegate Syntax C++

I am trying my hand at delegates in Unreal for the first time and I just cannot seem to get the syntax right. Any help would be greatly appreciated, thank you.

Class1.h

DECLARE_MULTICAST_DELEGATE(ON_LANGUAGE_CHANGE);

Class1

{
private:

                ON_LANGUAGE_CHANGE LanguageChangeDelegate;

}

Class1 cpp

void Class1::AFunction(FString target)

{

LanguageChangeDelegate.Add(this, &Class2::ADifferentFunctionInClass2, (FString)target);


if (LanguageChangeDelegate.IsBound())
{
	LanguageChangeDelegate.Broadcast(target);
}

}

Hi KaiL25,

You are using a delegate that doesn’t have parameters however you are passing through one. You should use DECLARE_MULTICAST_DELEGATE_OneParam.

Cheers,

Name and then param types, like this

DECLARE_MULTICAST_DELEGATE_OneParam(FOnLanguageChange,FString);

It’s not cocde breaker but in UE4 coding style delegates should be named same as structs so FSomethingSomething

There must be something else I’m missing. I am still getting errors.

125936-delegateserror1.jpg