# Best way to create and store a data type that might differ in number of variables with each entry

**URL:** <https://forums.unrealengine.com/t/best-way-to-create-and-store-a-data-type-that-might-differ-in-number-of-variables-with-each-entry/621630>\
**Category:** C++\
**Tags:** unreal-engine, UE5-0, question, CPP\
**Created:** [August 4, 2022, 11:36pm UTC](https://forums.unrealengine.com/t/best-way-to-create-and-store-a-data-type-that-might-differ-in-number-of-variables-with-each-entry/621630 "2022-08-04T23:36:08Z")\
**Posts on this page:** 1\
**Showing post:** 12

<div class="post-metadata">

**Author:** ![HHACarvalho](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@HHACarvalho](https://forums.unrealengine.com/u/HHACarvalho)\
**Post date:** [August 13, 2022, 4:21pm UTC](https://forums.unrealengine.com/t/best-way-to-create-and-store-a-data-type-that-might-differ-in-number-of-variables-with-each-entry/621630/12 "2022-08-13T16:21:36Z")

</div>

First of all, thanks to everyone who took their time to help me out!

### Here’s what ended up doing:

- As many of you suggested I created a struct and paired it with a Datatable to store the essential information about the weapons.

- I made an additional struct that extends the first one and adds a few more variables that don’t need to be saved in the Datatable (Ex: Current ammo inside the magazine).

- Instead of **AActor** , **WeaponBase** now extends **UObject** since **UObject** is the base class for all Unreal objects, and therefore, more lightweight. And also because actors are meant to be placed in the scene and that isn’t the case here.

- I also found a slightly more “elegant” way around the fact that you can’t use constructors with parameters in Unreal by following the solution provided by akaPrometh in this forum post: [Passing arguments to constructors in UE4? - #6 by akaPrometh](https://forums.unrealengine.com/t/passing-arguments-to-constructors-in-ue4/303372/6)

Brief explanation: You basically create a static method that instantiates the object, takes in the parameters you want and passes them to another non-static method that is going to assign the values to the variables (like a constructor would do).

Thanks again for all the help!

---

_[View the full topic](https://forums.unrealengine.com/t/best-way-to-create-and-store-a-data-type-that-might-differ-in-number-of-variables-with-each-entry/621630)._
