# C++ Interface: "Member Declation not allowed here".

**URL:** <https://forums.unrealengine.com/t/c-interface-member-declation-not-allowed-here/302207>\
**Category:** UI\
**Tags:** interface, ustruct, interfaces, unreal-engine, UInterface, CPP, question\
**Created:** [December 21, 2014, 10:57pm UTC](https://forums.unrealengine.com/t/c-interface-member-declation-not-allowed-here/302207 "2014-12-21T22:57:06Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jambax](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/jambax/32/904177_2.png) [@Jambax](https://forums.unrealengine.com/u/Jambax)\
**Post date:** [December 21, 2014, 10:57pm UTC](https://forums.unrealengine.com/t/c-interface-member-declation-not-allowed-here/302207/1 "2014-12-21T22:57:06Z")

</div>

I would like all of my instanced classes that feature the ‘IBZGame\_GameObjectInterface’ Interface, to have a UPROPERTY Struct that I can edit in all of the blueprints that I make of those classes.

So for example, my struct contains things such as ‘build cost’, or ‘build time’, and I want to be able to specify those in every class that has the GameObject interface, and expose the structs variables to Blueprints so that each BP class can have it’s own values.

However, when I try to declare a UPROPERTY in the interface class, I get the following compiler error, but I cannot understand why this won’t work, or how to work around it? (Note: Removing the UPROPERTY macro allows me to compile, but of course it means this variable won’t be exposed to blueprints of classes that have this interface).

```
UINTERFACE(MinimalAPI)
class UBZGame_GameObjectInterface : public UInterface
{
	GENERATED_UINTERFACE_BODY()

};

class BZGAME_API IBZGame_GameObjectInterface
{
	GENERATED_IINTERFACE_BODY()

	/* Return the GameObject Data for use */
	FORCEINLINE FGameObjectData GetGameObjectData() const { return GameObjectData; }

protected:
	/* Struct Containing All Relevant Game Object Information, such as Build Times, Resource Costs etc. */
	UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "GameObjectClass")
	FGameObjectData GameObjectData;
};

```

’

**The Error:**  
error : In BZGame\_GameObjectInterface: ‘Member variable declaration’ is not allowed here

How can I workaround this?

---

<div class="post-metadata">

**Author:** ![Rama](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/rama/32/882413_2.png) [@Rama](https://forums.unrealengine.com/u/Rama)\
**Post date:** [December 22, 2014, 8:08pm UTC](https://forums.unrealengine.com/t/c-interface-member-declation-not-allowed-here/302207/2 "2014-12-22T20:08:52Z")

</div>

#A Solution

You can make a virtual getter in your interface

```
virtual FYourDataStruct& GetDataStruct() = 0;

```

Then each class that implements the interface has to provide their stored version of the structure

But the end result is that you can perform logic on the data structure at the interface level, in the .cpp, using GetDataStruct() (even though it is pure virtual in the .h)

That’s as uniform as you can make it with an interface + variable data that is common to all extenders of the interface

To re-iterate, you then do the logic on the data structure in the .cpp of the interface itself.

Because the function is **returning by reference,** you are able to manipulate the data!

Any other class wanting to manipulate the data that is common to the interface can use the function too!

🙂

Rama

---

<div class="post-metadata">

**Author:** ![Jambax](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/jambax/32/904177_2.png) [@Jambax](https://forums.unrealengine.com/u/Jambax)\
**Post date:** [December 23, 2014, 10:43am UTC](https://forums.unrealengine.com/t/c-interface-member-declation-not-allowed-here/302207/3 "2014-12-23T10:43:49Z")

</div>

Thanks Rama! I need to look into this technique more 🙂

---

<div class="post-metadata">

**Author:** ![robbiecooper](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@robbiecooper](https://forums.unrealengine.com/u/robbiecooper)\
**Post date:** [December 30, 2014, 5:13pm UTC](https://forums.unrealengine.com/t/c-interface-member-declation-not-allowed-here/302207/4 "2014-12-30T17:13:06Z")

</div>

Hey The Jamsh

Did Rama’s solution work? I’m trying to get a very similar thing working, but still getting the error you reported, after using Rama’s solution. Cheers

---

<div class="post-metadata">

**Author:** ![robbiecooper](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@robbiecooper](https://forums.unrealengine.com/u/robbiecooper)\
**Post date:** [December 31, 2014, 4:02pm UTC](https://forums.unrealengine.com/t/c-interface-member-declation-not-allowed-here/302207/5 "2014-12-31T16:02:26Z")

</div>

Hey The Jamsh, I think the struct has to be static. But I don’t think you can make a static variable a uproperty…

---

<div class="post-metadata">

**Author:** ![rob422lou](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/rob422lou/32/88719_2.png) [@rob422lou](https://forums.unrealengine.com/u/rob422lou)\
**Post date:** [May 18, 2015, 9:45pm UTC](https://forums.unrealengine.com/t/c-interface-member-declation-not-allowed-here/302207/6 "2015-05-18T21:45:22Z")

</div>

I can’t seem to make this work with blueprints. The function doesn’t show up in the editor, and any combination of UFunction with specifiers that tell the blueprint that it can implement the function doesn’t compile. Any suggestions?

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_564f6a11](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_564f6a11](https://forums.unrealengine.com/u/anonymous_user_564f6a11)\
**Post date:** [May 14, 2019, 10:09pm UTC](https://forums.unrealengine.com/t/c-interface-member-declation-not-allowed-here/302207/7 "2019-05-14T22:09:02Z")

</div>

,The Issue is with the UPROPERTY().You need to remove all UPROPERTY() in the interface for you to build
