# Always initialize a member variable (type.6) c++

**URL:** <https://forums.unrealengine.com/t/always-initialize-a-member-variable-type-6-c/591727>\
**Category:** C++\
**Tags:** UProperty, unreal-engine, UE5-0, Blueprint, CPP, question\
**Created:** [June 27, 2022, 3:04pm UTC](https://forums.unrealengine.com/t/always-initialize-a-member-variable-type-6-c/591727 "2022-06-27T15:04:29Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Panais121](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Panais121](https://forums.unrealengine.com/u/Panais121)\
**Post date:** [June 27, 2022, 3:04pm UTC](https://forums.unrealengine.com/t/always-initialize-a-member-variable-type-6-c/591727/1 "2022-06-27T15:04:29Z")

</div>

Hello , im having some warnings in the (Cpp file) saying that some variables are uninitialized and i cant understand why .Btw i think everything set right in the Header file of my project

 ![Screenshot 2022-06-27 150310](https://d3kjluh73b9h9o.cloudfront.net/original/4X/8/f/d/8fdded8c1ba9e6836881977b82f17006305939b2.png)  
 ![Screenshot 2022-06-27 150828](https://d3kjluh73b9h9o.cloudfront.net/original/4X/1/7/4/174a975904429043466e584f99acdd0d349fb4c4.png)

---

<div class="post-metadata">

**Author:** ![Chatouille](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/chatouille/32/1194622_2.png) [@Chatouille](https://forums.unrealengine.com/u/Chatouille)\
**Post date:** [June 27, 2022, 3:07pm UTC](https://forums.unrealengine.com/t/always-initialize-a-member-variable-type-6-c/591727/2 "2022-06-27T15:07:32Z")

</div>

Add default values in your constructor :

```cpp
AShooterCharacter::AShooterCharacter()
{
    FireSound = NULL;
    MuzzleFlash = NULL;
    HipFireMontage = NULL;
}

```

---

<div class="post-metadata">

**Author:** ![Panais121](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Panais121](https://forums.unrealengine.com/u/Panais121)\
**Post date:** [June 28, 2022, 7:30am UTC](https://forums.unrealengine.com/t/always-initialize-a-member-variable-type-6-c/591727/3 "2022-06-28T07:30:38Z")

</div>

Thank you a lot!!

---

<div class="post-metadata">

**Author:** ![MagForceSeven](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/magforceseven/32/906563_2.png) [@MagForceSeven](https://forums.unrealengine.com/u/MagForceSeven)\
**Post date:** [June 28, 2022, 1:31pm UTC](https://forums.unrealengine.com/t/always-initialize-a-member-variable-type-6-c/591727/4 "2022-06-28T13:31:16Z")

</div>

You can also initialize members in the header like:  
`class UParticleSystem *MuzzleFlash = nullptr;`  
but that’s strictly a style issue.

More importantly you should be using `nullptr` over `NULL`.

---

<div class="post-metadata">

**Author:** ![Panais121](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Panais121](https://forums.unrealengine.com/u/Panais121)\
**Post date:** [July 7, 2022, 10:18am UTC](https://forums.unrealengine.com/t/always-initialize-a-member-variable-type-6-c/591727/5 "2022-07-07T10:18:18Z")

</div>

Okayy thanks for the help
