Multiple inheritance

Hi another question on my end.

So I know multiple inheritance isn’t possible in UE4 C++, which is sad. But what is the best approach then to work with “generic” features.

Simplest version of the example:
I would like to inherit from AActor and UDebug, now UDebug is just a UObject, why? Well I would like to be able to debug more than just AActors. Say I’d want to debug a … I don’t know GameMode? (bit silly example I know but bear with me)

Now it would be silly to have UDebug inherit AActor as it doesn’t need all the extra information. All it wants to do is do debug stuff. So best way to resolve this is ofc have the target inherit from both UDebug and AActor. but yeh not possible.

How to still have this effect without the possibility of multiple inheritance, what would be the right approach?

Are you talking about debug helpers? You can include debug helpers into any file you want to access their functionality.

nah debug is just one of the examples I’m using. let’s rename UDebug to UPika … :stuck_out_tongue:

I was thinking along the lines of composition pattern, but I can’t seem to get the composite subclass exposed to the editor.

Like I’m using:

public:

	UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="Blaat")
	UBaseItem * BaseItem = NewObject<UBaseItem>();

But the property is visible in the editor but not instanciated

there no such things as “UE4 C++” it normal C++, It is supported you just can do it with UObject, UObject classes need to be registed to reflection system in order to work, so it need UCLASS and UHT need to parse and it will break compilation prevent it… but i does not change the fact compiler would pass it thru… and btw UHT will let you parent UObject class with non you object class which is viable option and classes like that you can find in the engine, like UObject:

You also have interfaces which C++ don’t really have, but they are amulated using multiparenting feature of C++ that UE4 reflection system recognize:

Which in C++ it can also have functions same as UStruct structs, because again this is normal C++.

But you can also make your debugger UActorComponent that you can attach to actor so it is still UObject and can be attached to actor to analyze actor and do debug stuff.