# How to setup your constructor?

**URL:** <https://forums.unrealengine.com/t/how-to-setup-your-constructor/329584>\
**Category:** C++\
**Tags:** constructors, unreal-engine, UE4, CPP, question\
**Created:** [August 22, 2015, 7:08pm UTC](https://forums.unrealengine.com/t/how-to-setup-your-constructor/329584 "2015-08-22T19:08:20Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![BitBoy92](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@BitBoy92](https://forums.unrealengine.com/u/BitBoy92)\
**Post date:** [August 22, 2015, 7:08pm UTC](https://forums.unrealengine.com/t/how-to-setup-your-constructor/329584/1 "2015-08-22T19:08:20Z")

</div>

Hello Everybody,

My question stems from an answer I received in this [post](https://answers.unrealengine.com/questions/286958/problems-with-using-a-toctree.html). Essentially, I had to change my constructor to use const FObjectInitializer& ObjectInitializer as a parameter. So this has led me to ask the question of, “ **How do you know how to setup your constructor.** ” For instance when should you use a regular constructor that doesn’t take in any parameters like the ones that are generated for you when you create an AActor class and when should you use constructors with parameters like those that I mentioned above?

I am still very new to Unreal Real C++ programming so any help is very much appreciated,

Farshooter

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_10b2fd67](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_10b2fd67](https://forums.unrealengine.com/u/anonymous_user_10b2fd67)\
**Post date:** [August 22, 2015, 7:48pm UTC](https://forums.unrealengine.com/t/how-to-setup-your-constructor/329584/2 "2015-08-22T19:48:24Z")

</div>

You should check out this page as it goes into the UObject architecture (which is where that constructor comes from):

> **[Gameplay Classes](https://docs.unrealengine.com/5.2/en-US/gameplay-classes-in-unreal-engine/)**
>
> Reference for creating and implementing gameplay classes.

Basically, anything that inherits from UObject (AActor, etc) needs to implement that UObject default constructor that takes in the FObjectInitializer parameter.

When in doubt, read the header files of the classes you are inheriting from and see how their constructors are laid out.

That’s how I knew which Octree constructor you needed to use.

```
	/** Initialization constructor. */
	TOctree(const FVector& InOrigin,float InExtent);

#if WITH_HOT_RELOAD_CTORS
	/** DO NOT USE. This constructor is for internal usage only for hot-reload purposes. */
	TOctree();
#endif // WITH_HOT_RELOAD_CTORS

```

---

<div class="post-metadata">

**Author:** ![BitBoy92](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@BitBoy92](https://forums.unrealengine.com/u/BitBoy92)\
**Post date:** [August 22, 2015, 8:25pm UTC](https://forums.unrealengine.com/t/how-to-setup-your-constructor/329584/3 "2015-08-22T20:25:08Z")

</div>

This was exactly what I was looking for.

Thanks again for all your help @AdeptStrain,

Farshooter
