# How can I achieve something akin to multiple inheritance in UE5?

**URL:** <https://forums.unrealengine.com/t/how-can-i-achieve-something-akin-to-multiple-inheritance-in-ue5/1184937>\
**Category:** Programming & Scripting\
**Tags:** unreal-engine, question\
**Created:** [May 31, 2023, 8:44pm UTC](https://forums.unrealengine.com/t/how-can-i-achieve-something-akin-to-multiple-inheritance-in-ue5/1184937 "2023-05-31T20:44:52Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![dbrespawn](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@dbrespawn](https://forums.unrealengine.com/u/dbrespawn)\
**Post date:** [May 31, 2023, 8:44pm UTC](https://forums.unrealengine.com/t/how-can-i-achieve-something-akin-to-multiple-inheritance-in-ue5/1184937/1 "2023-05-31T20:44:52Z")

</div>

I’m working on implementing the save system for our game and I’m trying to do it in a way that doesn’t require modifying engine code.

The plan is to have a flag (among other things) on the actor that determines if it needs to be saved. We have our own class that inherits from AActor which is good there but it gets complicated when we start considering things like ACharacter (which we also have our own version of) or other things that indirectly inherit from AActor.

I want to avoid duplicating code on a bunch of classes. How I would normally do that would be with an “interface class” (yes, I know it’s not a real interface) that has a set of functions, some of them pure virtual, and a few member variables, such as the flag that marks it as should save.

In Unreal, this isn’t really possible with the way the UObject inheritance system works. The only way, as far as I can tell, to have multiple inheritance is to use a UINTERFACE but those don’t allow for properties.

How can I implement identical properties and logic in several different classes without code duplication such that I can edit those properties from within the editor?

---

<div class="post-metadata">

**Author:** ![BIGTIMEMASTER](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/bigtimemaster/32/710746_2.png) [@BIGTIMEMASTER](https://forums.unrealengine.com/u/BIGTIMEMASTER)\
**Post date:** [May 31, 2023, 8:49pm UTC](https://forums.unrealengine.com/t/how-can-i-achieve-something-akin-to-multiple-inheritance-in-ue5/1184937/2 "2023-05-31T20:49:35Z")

</div>

Would an actor component not work?

can attach to any actor, it can house both data and logic

---

<div class="post-metadata">

**Author:** ![dbrespawn](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@dbrespawn](https://forums.unrealengine.com/u/dbrespawn)\
**Post date:** [May 31, 2023, 9:37pm UTC](https://forums.unrealengine.com/t/how-can-i-achieve-something-akin-to-multiple-inheritance-in-ue5/1184937/3 "2023-05-31T21:37:48Z")

</div>

On paper, that would work but there’s some complexity I haven’t gone into that makes it a less ideal choice.

After a chat with some coworkers, I think what I’m going to do is use an UINTERFACE, add some pure virtual getters, and then make a preprocessor macro that the inheriting classes can use. This will avoid a bunch of copy+paste boilerplate code while still giving me a common interface to work with.
