# C++: Easy way to save a structure.

**URL:** <https://forums.unrealengine.com/t/c-easy-way-to-save-a-structure/432589>\
**Category:** Editor Scripting\
**Tags:** savegame, Structure, unreal-engine, CPP, question, structs\
**Created:** [August 27, 2018, 8:36pm UTC](https://forums.unrealengine.com/t/c-easy-way-to-save-a-structure/432589 "2018-08-27T20:36:28Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Aneos](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Aneos](https://forums.unrealengine.com/u/Aneos)\
**Post date:** [August 27, 2018, 8:36pm UTC](https://forums.unrealengine.com/t/c-easy-way-to-save-a-structure/432589/1 "2018-08-27T20:36:28Z")

</div>

Hi. I’d like to save an array of structures from my player controller to a save game class. I could easely save other types of variables, because you can just create a variable and then transfer it. But if I create the exact same structure in the save game class, I can’t pass over the struct.  
So do I have to break the struct up and send every variable alone? Because my struct is pretty big and so I’d like to have an other option. Thanks!

---

<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:** [August 27, 2018, 10:12pm UTC](https://forums.unrealengine.com/t/c-easy-way-to-save-a-structure/432589/2 "2018-08-27T22:12:24Z")

</div>

You don’t need to declare 2nd identical structure, just forward reference (put struct before the type) the structure in save game class and UHT and UE4 reflection system will know which structure you use, you will only need to include deceleration in cpp file when you gonna copy the data so compiler will know which structure you use, but you need to do it anyway.

---

<div class="post-metadata">

**Author:** ![Aneos](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Aneos](https://forums.unrealengine.com/u/Aneos)\
**Post date:** [August 28, 2018, 4:56pm UTC](https://forums.unrealengine.com/t/c-easy-way-to-save-a-structure/432589/3 "2018-08-28T16:56:13Z")

</div>

Thx for the reply. But could you pls give me an example? ` forward reference (put struct before the type) the structure` I didn’t really get this part. How do I forward reference the structure?

---

<div class="post-metadata">

**Author:** ![Aneos](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Aneos](https://forums.unrealengine.com/u/Aneos)\
**Post date:** [August 31, 2018, 5:27pm UTC](https://forums.unrealengine.com/t/c-easy-way-to-save-a-structure/432589/4 "2018-08-31T17:27:23Z")

</div>

I tried it now many times and I don’t think I can get a solution. Could you pls send me an example?
