Interface as UPROPERTY, class member? [C++]


To create an interface you must create two classes, one with the macro UINTERFACE which is deriving UInterface and one “normal” class that contains all the interface’s pure virtual methods. Is this correct understood? source: [Question] C++ Interfaces? - UI - Unreal Engine Forums.

When I have created my interface it seems like it can’t be used as a UPROPERTY and therefore not automatically added to the garbage collector. What type of pointer should one use to make a UINTERFACE a member of an other UCLASS such that it’s managed by the garbage collector and references are increased and decreased properly? Is there some equivalent to std::unique_ptr from C++11 for unique objects? The UINTERFACE will only be implemented by classes that inherits UObject.

As a side note:
I also tried to make an abstract UCLASS but seems like an UCLASS can’t have pure virtual members even though it’s created with UCLASS(Abstract). This seems a bit weird to me since having abstract/pure virtual methods is pretty much what makes an abstract class abstract except in some special cases.
I get the following compilation error message:

error C2259: 'UGUIComponent' : cannot instantiate abstract class due to following members: 'void UGUIComponent::test(void)' : is abstract

where UGUIComponent is my class with the method virtual void test() = 0;

#Inherit Interfaces

You use multiple inheritance with interfaces, so for any class you want to implement an interface, you add the additional inheritance.

I have entire instructions and complete tutorial on interfaces here:

#UE4 Interfaces Wiki