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

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


Add default values in your constructor :

AShooterCharacter::AShooterCharacter()
{
    FireSound = NULL;
    MuzzleFlash = NULL;
    HipFireMontage = NULL;
}
1 Like

Thank you a lot!!

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.

1 Like

Okayy thanks for the help