# Why UPROPERTY doesn't work in Interface?

**URL:** <https://forums.unrealengine.com/t/why-uproperty-doesnt-work-in-interface/917335>\
**Category:** C++\
**Tags:** interface, UProperty, interaction, unreal-engine, question, CPP\
**Created:** [April 13, 2023, 11:41am UTC](https://forums.unrealengine.com/t/why-uproperty-doesnt-work-in-interface/917335 "2023-04-13T11:41:20Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Aragam113](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/aragam113/32/632861_2.png) [@Aragam113](https://forums.unrealengine.com/u/Aragam113)\
**Post date:** [April 13, 2023, 11:41am UTC](https://forums.unrealengine.com/t/why-uproperty-doesnt-work-in-interface/917335/1 "2023-04-13T11:41:20Z")

</div>

I have a boolean variable in my Interaction Interface, i need to edit this boolean on scene (EditAnywhere), but when i add UPROPERTY it happens:  
 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/a/1/5/a156e050f3e9fd06aa695118dcb5da4c54bfc85b.png)

```cpp
public:
	virtual void InteractionWithMe();
	virtual void ShowInteractionWidget();
	virtual void HideInteractionWidget();
	virtual void SetOutline();
	virtual void RemoveOutline();
	virtual void SetElectricMod();
	virtual void SetOrganicMod();
	virtual void DisableModes();
	virtual void InteractAnyway();

	UPROPERTY(EditAnywhere, BlueprintReadWrite)
	bool bInteractAnyway = false;

```

how i can add UPROPERTY in my interface?

---

<div class="post-metadata">

**Author:** ![MagForceSeven](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/magforceseven/32/906563_2.png) [@MagForceSeven](https://forums.unrealengine.com/u/MagForceSeven)\
**Post date:** [April 13, 2023, 1:28pm UTC](https://forums.unrealengine.com/t/why-uproperty-doesnt-work-in-interface/917335/2 "2023-04-13T13:28:55Z")

</div>

You can’t. Interfaces are _by definition_ classes without properties. And although you won’t get any UHT or compiler complaints about it, they shouldn’t have any non-property member variables either.

This is to prevent “the diamond problem” with multiple inheritance in C++. If there are no members, then you can sort of ignore the inheritance issues.

One solution is a virtual function and either storing the value in the derived type to be returned by an override.  
Alternatively it’s worth considering (if you want common data) that perhaps your interface should actually be a component instead.

---

<div class="post-metadata">

**Author:** ![Aragam113](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/aragam113/32/632861_2.png) [@Aragam113](https://forums.unrealengine.com/u/Aragam113)\
**Post date:** [April 13, 2023, 1:45pm UTC](https://forums.unrealengine.com/t/why-uproperty-doesnt-work-in-interface/917335/3 "2023-04-13T13:45:34Z")

</div>

Thanks, while I was waiting for an answer, I already changed the structure of this code, everything works. Thank you for your reply, you helped me learn more about this
