Interface in C++; can you pass variables between objects of different classes?

I realize that this is an old post and you have probably found the correct path by now, but just in case anyone else comes to this post looking for answers.

It is totally possible to use interfaces in UE4 to communicate between different object types … I even use interfaces for interaction with various blueprint types so that they can be used by any class that implements that interface very successfully.

Here is a small sample from my TPP Controller interface

class MYGAME_API UTPPControllerInput : public UInterface
{
    GENERATED_UINTERFACE_BODY()
};

class MYGAME_API ITPPControllerInput
{
    GENERATED_IINTERFACE_BODY()

public:
    UFUNCTION(BlueprintNativeEvent, BlueprintCallable, Category = "Controller Input")
    void Invoke_Crouch();
}

As you can see no static is required

You can use this in C++ like this (can be a member variable or local variable)

TScriptInterface<ITPPControllerInput> tppInterface;
if (myImplementation->GetClass()->ImplementsInterface(UTPPControllerInput::StaticClass()))
{
    tppInterface.SetInterface(dynamic_cast<ITPPControllerInput*>(myImplementation));
    tppInterface.SetObject(myImplementation);
}
tppInterface->Execute_Invoke_Crouch(myImplementation);

This interface can also be called directly from blueprints (e.g. character blueprint or animation blueprint) and is useful for having single animation blueprint usable by any class that implements this interface.