# Compiler generates an error for the specified attribute of class

**URL:** <https://forums.unrealengine.com/t/compiler-generates-an-error-for-the-specified-attribute-of-class/369226>\
**Category:** Programming & Scripting\
**Tags:** unreal-engine\
**Created:** [September 3, 2016, 12:57pm UTC](https://forums.unrealengine.com/t/compiler-generates-an-error-for-the-specified-attribute-of-class/369226 "2016-09-03T12:57:14Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Relrin](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Relrin](https://forums.unrealengine.com/u/Relrin)\
**Post date:** [September 3, 2016, 12:57pm UTC](https://forums.unrealengine.com/t/compiler-generates-an-error-for-the-specified-attribute-of-class/369226/1 "2016-09-03T12:57:14Z")

</div>

I’m trying to implement weapon holding by monsters. The C++ compiler of UE4/XCode warn me, that AActor doesn’t have the `WeaponHolder` attribute. That’s current state of my code:

1. MeleeWeapon.h

2. Monster.h

3. Monster.cpp

So, this is the error, which I was taken from the compiler:

```
Info Total build time: 60,11 seconds
Info Setting up Mono
Info /Users/Shared/UnrealEngine/4.11/Engine /Users/Shared/UnrealEngine/4.11/Engine/Binaries/Mac
Info Compiling game modules for hot reload
Info Compiling with MacOSX SDK 10.11
Info Parsing headers for LearnUE4CppAndActorsEditor
Info Running UnrealHeaderTool "/Users/savicvalera/Documents/Unreal Projects/LearnUE4CppAndActors/LearnUE4CppAndActors.uproject" "/Users/savicvalera/Documents/Unreal Projects/LearnUE4CppAndActors/Intermediate/Build/Mac/LearnUE4CppAndActorsEditor/Development/UnrealHeaderTool.manifest" -LogCmds="loginit warning, logexit warning, logdatabase error" -Unattended -WarningsAsErrors -installed
Info Reflection code generated for LearnUE4CppAndActorsEditor in 12,3825563 seconds
Info Performing 5 actions (4 in parallel)
Info [3/5] Compile MeleeWeapon.cpp
Info [2/5] Compile Monster.cpp
Info [1/5] Compile LearnUE4CppAndActors.generated.cpp
Info /Users/savicvalera/Documents/Unreal Projects/LearnUE4CppAndActors/Source/LearnUE4CppAndActors/Monster.cpp:70:26: error: no member named 'WeaponHolder' in 'AActor'
Info MeleeWeapon->WeaponHolder = this;
Info ~~~~~~~~~~~ ^
Info 1 error generated.
Info -------- End Detailed Actions Stats -----------------------------------------------------------
Info ERROR: UBT ERROR: Failed to produce item: /Users/savicvalera/Documents/Unreal Projects/LearnUE4CppAndActors/Binaries/Mac/UE4Editor-LearnUE4CppAndActors-3898.dylib
Info 
Info Running Mono...
Info 

```

What I doing wrong there? All required fields were described for AMeleeWeapon and Monster classes.

P.S. “How to” for this game features are described in the “Learning C++ by creating games with UE4” by William Sherif. However that functionality described for older versions of Unreal Engine.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_4b3639a6](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_4b3639a6](https://forums.unrealengine.com/u/anonymous_user_4b3639a6)\
**Post date:** [September 3, 2016, 1:57pm UTC](https://forums.unrealengine.com/t/compiler-generates-an-error-for-the-specified-attribute-of-class/369226/2 "2016-09-03T13:57:27Z")

</div>

Hey Relrin

Try to give your variables and methods a scope by adding  
public: after you GENERATED\_UCLASS\_BODY Makro

Greetings

---

<div class="post-metadata">

**Author:** ![Shadowriver](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Shadowriver](https://forums.unrealengine.com/u/Shadowriver)\
**Post date:** [September 3, 2016, 3:30pm UTC](https://forums.unrealengine.com/t/compiler-generates-an-error-for-the-specified-attribute-of-class/369226/3 "2016-09-03T15:30:37Z")

</div>

You operate on AActor pointer and from that pointer only AActor class content is accessible and WeaponHolder is indeed not part of it as error say, so you need to change change `AActor* MeleeWeapon;` to `AMeleeWeapon* MeleeWeapon;`
