Pointer Asterisk location from header to cpp

I’m currently creating the projectile in the Unreal 5.0 C++ Developer: Learn C++ and Make Video Games course, and I couldn’t help but notice that a function in the header file with pointers in it changes the location of the asterisk in the cpp file. Why is this? I tried both ways, and both ways worked. Just wondering what is proper.


It is a matter of style.
“UPrimitiveComponent HitComp" can be read as sending a pointer to a HitComp object
"UPrimitiveComponent
HitComp” can be read as sending a pointer object HitComp of type UPrimitiveComponent.

Both are valid. The compiler is smart enough to know that the reference to HitComp is a pointer.

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms