Don't forward declare inline

I wouldn’t recommend the video’s way of doing forward declaration. It’s better IMHO to forward declare outside the class:

class UCapsuleComponent;

UCLASS()
class TOONTANKS_API ABasePawn : public APawn {
   [...]
   UCapsuleComponent* capsule;
   [...]
};

The problem with inline forward declare is that it can be confusing if one declares a nested class with the same name (example.
Here it’s unlikely to cause problem (one should be creating a nested class call UCapsuleComponent), but it’s not good practice in general and should be avoided.

Privacy & Terms