C++ Custom Class variable

So in BP you can make any Blueprint you created a variable Type. I could have a Blueprint named Item and in another BP i can have an array which stores this type of BP.
Now to my Question. How can I achieve this in c++? I made a custom Actor Class named Item. And now i want that type of class being an Array type in another Blueprint.

Hey Thorwin99-

Are you trying to get your Item class to be a type inside another class or inside a variable? If you want to use the Item class inside another class, you will first need to add an include statement for the Item class header file into the second class where you’re trying to use it. This will allow the second class to accept Item as a variable type. If you are trying to make an array of Items like this, you would use TArray< AItem > MyItemArray; as your declaration.

If you want to use your custom class as an array inside a blueprint, then the setup is actually the same as if you’re using a blueprint. You can simply add a new variable and set it’s type to be a reference to your Item class and convert it to an array inside the blueprint.

Cheers

Thank you, that answer worked well. I tried that before but i messed something with the include up.

For anyone else asking this question, the syntax is class YourCustomClass* VariableName;
This declares a pointer (* being the pointer operator) variable in which you can store an object of your class (forward-declaring). My example creates only a single variable, rather than an array. Including the header file of the class to be stored is always required.