class UTargetInterface : public UInterface
I am working on creating a interface in code and was wondering what the need was for having both the Uinterface and Iinterface class declarations when implementing the interface.
If anyone could explain it to me that would be great
The UInterface is the UObject which holds all the reflection information about the interface. As it’s a UObject, it has all the facilities you normal expect from a UObject (has a name, can be serialised, can be reflected, etc.).
The IInterface is the actual native class which the compiler uses to inject virtual functions into your class, generated the correct vtable entries, make calls through etc.
The IInterface cannot be a UInterface (and thus a UObject) for several reasons, but the major one is that UObjects are intended to form a cosmic hierarchy and inheriting an IThing which was also a UObject would mean your class would have multiple UObject bases, which leads to the usual diamond-shaped inheritance problem: Multiple inheritance - Wikipedia
We recognise that it’s a bit clunky and would like to clean it up so that the UInterface is implicitly generated, but we currently have no timescale for that to happen.