In C++ if something is a UProperty I always assume it will be initialized to some default, usually 0 for numbers, for example.
Normally in C++ if you don’t initialize a member variable it’ll have garbage of whatever is in memory. I noticed, however, in Unreal, I have some C++ only member vars in some of my UObjects that I forgot to explicitly initialize, and I haven’t had any issues.
Does Unreal know to somehow zero out member vars when it’s a UObject?
You should always initialize your variables, or something else will. You may get lucky and UObjects get memset to 0 for their POD types somewhere, but I wouldn’t take that chance. Also, remember that uninitialized variables will be set to 0 in DEBUG, but random memory in SHIPPING / RELEASE.
Yeah +1 for initializing anyway, it’s a good habit to get into.
I’m not 100% sure but I seem to recall somebody saying that the memory footprint of a UObject will be mem-zeroed first, before being reinitialized with the class-default object, so by sheer luck it might be that everything is zero initially - but it’s not a chance worth taking, and that still doesn’t garauntee the type will be ‘safe’.