Calling c++ interfaces?

Hey guys,

I have a BaseClass that’s an Interface and a DerivedClass that inherits from that interface. I have another class say GameManager
that I want to wrangle all of the many interfaces I will have.

In my GameManager class, I need to call functions from the DerivedClass. I’m pretty sure that I need to spawn the DerivedClass and then cast from my BaseClass interface to it?

This is the step that confuses me because I’m not sure what exactly I need to do. If anyone could provide examples with code that would be incredibly helpful, I’ve been stuck on this problem for a while now and the wiki and docs don’t really help me with my use case. For example, in Rama’s wiki post, I’m unsure how they are using this reference:

//Some pointer is defined to any class inheriting from UObject
UObject* pointerToAnyUObject;

If you are talking about an unreal interface… ie one of these:

UINTERFACE(Blueprintable, meta = (CannotImplementInterfaceInBlueprint))
class UUGInterface : public UInterface
{
	GENERATED_UINTERFACE_BODY()
};

class IUGInterface
{
	GENERATED_IINTERFACE_BODY()

};

Then to convert a UObject to the interface you go:

IUGInterface* Interface = Cast<IUGInterface>(pointerToAnyUObject);

Then you can call any functions that are part of that interface.
Is this what you meant?

To add onto this, check out this Unreal engine wiki page

It has a decent example and explanation.