# Cyclic dependency on header files

**URL:** <https://forums.unrealengine.com/t/cyclic-dependency-on-header-files/313745>\
**Category:** Programming & Scripting\
**Tags:** unreal-engine\
**Created:** [April 4, 2015, 1:30am UTC](https://forums.unrealengine.com/t/cyclic-dependency-on-header-files/313745 "2015-04-04T01:30:19Z")\
**Posts on this page:** 1\
**Showing post:** 4

<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:** [April 4, 2015, 5:46am UTC](https://forums.unrealengine.com/t/cyclic-dependency-on-header-files/313745/4 "2015-04-04T05:46:34Z")

</div>

#Wiki For You

I polished and updated my Wiki on Forward Declaration, just forward declare your character class in your inventory class

> **[A new, community-hosted Unreal Engine Wiki](https://forums.unrealengine.com/t/a-new-community-hosted-unreal-engine-wiki/141494)**
>
> After over a year in maintenance mode, the official Unreal Engine Wiki is now permanently offline. These resources now live on a new community-run Unreal Engine Community Wiki — ue4community.wiki! You will be able to find content from the official...

#Solution For You in Exact Detail

include your inventory class at the top of your character class

then you should #include your character class only in the .cpp file of your inventory class, avoid trying to access your character class in your inventory .h, You use forward declaration to include a pointer to your character class in your inventory .h, but you dont access its vars in the .h, only in the .cpp

#Summary

inventory class **.h** → forward declares character class (see wiki)

inventory class. **cpp** → now you can #include character class and actually access its functions and vars

character class **.h** → #include your inventory class, use inventory however you like in .h or .cpp

#Wiki Link

**UE4 Forward Declaration**

> **[A new, community-hosted Unreal Engine Wiki](https://forums.unrealengine.com/t/a-new-community-hosted-unreal-engine-wiki/141494)**
>
> After over a year in maintenance mode, the official Unreal Engine Wiki is now permanently offline. These resources now live on a new community-run Unreal Engine Community Wiki — ue4community.wiki! You will be able to find content from the official...

Rama

PS: dont mess with the UE4 auto-generated classes files, just do the above, you should make edits only to inventory and character classes at your project level.

---

_[View the full topic](https://forums.unrealengine.com/t/cyclic-dependency-on-header-files/313745)._
