# Issue Converting Blueprints to C++

**URL:** <https://forums.unrealengine.com/t/issue-converting-blueprints-to-c/235518>\
**Category:** C++\
**Tags:** unreal-engine, UE4-25\
**Created:** [June 15, 2021, 4:02am UTC](https://forums.unrealengine.com/t/issue-converting-blueprints-to-c/235518 "2021-06-15T04:02:48Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![cpioli](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@cpioli](https://forums.unrealengine.com/u/cpioli)\
**Post date:** [June 15, 2021, 4:02am UTC](https://forums.unrealengine.com/t/issue-converting-blueprints-to-c/235518/1 "2021-06-15T04:02:48Z")

</div>

I implemented a state system. Parent (abstract) base class is in C++ (child of UObject), actual classes are blueprints. Blueprints aren’t objects though, so I have to instantiate each class once and save them into a Map\<ControlInputStateBase “Class Reference”, ControlInputStateBase\>. I do this in the ThirdPersonController’s Constructor.

I have five states now and my Constructor is turning into spaghetti, so I want to simplify things by converting this into C++. _My problem_ is that I am unsure how to declare the TMap because I do not know what the C++ equivalent is to a “Class Reference” type.

My first idea was to use TSubclassOf like this:

TMap\<TSubclassOf, UControlInputStateBase\> stateRepository;

But it gives me five errors, e.g. ‘UControlInputStateBase’: undeclared identifier" and “UControlInputStateBase is not a valid identifier.” I also tried using an enum, but I got another error “TDefaultMapHashableKeyFuncs: unspecialized class template can’t be used as a template argument for template parameter ‘KeyFuncs’” so enums are out, too, I suppose.

Does anyone know how I can fix my current problem? Thank you in advance!

---

<div class="post-metadata">

**Author:** ![STRiFE.x](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/strife.x/32/969826_2.png) [@STRiFE.x](https://forums.unrealengine.com/u/STRiFE.x)\
**Post date:** [June 15, 2021, 7:17am UTC](https://forums.unrealengine.com/t/issue-converting-blueprints-to-c/235518/2 "2021-06-15T07:17:10Z")

</div>

> [@cpioli](#):
>
> I do not know what the C++ equivalent is to a “Class Reference” type

To be perfectly honest, if you don’t understand core concepts like these, then there is no point in converting to C++. You’ll just end up with more mess. You can learn the basics of C++ in a few days.

---

<div class="post-metadata">

**Author:** ![cpioli](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@cpioli](https://forums.unrealengine.com/u/cpioli)\
**Post date:** [June 22, 2021, 10:50pm UTC](https://forums.unrealengine.com/t/issue-converting-blueprints-to-c/235518/3 "2021-06-22T22:50:05Z")

</div>

Well I know C++. I’m not asking to make a reference to an object, that’s a piece of cake and I’ve been doing it for years. What I specifically meant was: there’s a variable type in Blueprints called a “Class Reference” I am using in my Blueprint, but you never reference “classes” in C++ - only objects (there is an Object Reference type in Blueprints as well).

C++ barely has introspection as it is, so I’m assuming Class Reference is something Epic built on top of C++ in its Unreal Header or Builder Toolkits. Although I should really read through those again.

---

<div class="post-metadata">

**Author:** ![cpioli](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@cpioli](https://forums.unrealengine.com/u/cpioli)\
**Post date:** [June 22, 2021, 11:32pm UTC](https://forums.unrealengine.com/t/issue-converting-blueprints-to-c/235518/4 "2021-06-22T23:32:05Z")

</div>

Thanks! Once I made that change, I could debug the rest of the issues. (1. I forgot to add “#include ‘ControlInputStateBase.h’” and (2) I needed to make a forward declaration due to a circular dependency).

Edit: I still get this Error (but the code still reloads into the Unreal project)

`LogCompile : error : Circular dependency detected for filename D:\git repositories\UE4_ThirdPersonController\Source\ThirdPersController\Public\ControlInputStateBase.h!`

Adding a forward declaration of `class AInputStateMachineCharacter;` to fix the issue actually causes UE4.25 to crash. The project can “live” without it (ie changes are still sent to the Unreal Engine project), but I am unsure if this will cause any problems later in development.

I’m also changing my variables to use PascalCase like you suggested.
