No need for forward declaration on Tank.h

Why do we need a forward declaration of UTankBarrel in Tank.h ?

Tank.h includes TankAimingComponent.h which already has a forward declaration of UTankBarrel.

Therefore, it seems to me that the second forward declaration is redundunt.

I just now went through this and agree with you. I did not forward declare within my Tank.h and everything compiled nicely due to the inclusion of TankAimingComponent.h. I believe, at this point, that it is more for readability than actual need, despite Ben’s statement that intellisense will complain. Without the forward declaration, if you look at the code with ‘fresh eyes’, you do not really know where UTankBarrel came from unless you trace down ‘every’ header file. Good thing there are not that many.

1 Like

Privacy & Terms