It’s bad practice though, as it can go horribly wrong in the presence of namespaces and doesn’t really work for templates and enums. We try to discourage it, but some existing code (and occasionally new code) has it.
If you want a declaration, it should always be done at the correct scope (usually global scope), like this:
namespace X
{
// Will compile as taking ::Y* if a global Y has seen already, or as taking X::Y* if it hasn’t
void Func(class Y* Param);
}
// Will compile only if A::B has been declared already, making it redundant as a forward declaration
void Func2(class A::B* Param);
…but, just a curiosity about that case in Character.h.
At the top there is a forward declaration, then variables and functions with ‘elaborated type specifier’ for the same class:
class USkeletalMeshComponent;
class ENGINE_API ACharacter : public APawn
{
class USkeletalMeshComponent* Mesh;
class USkeletalMeshComponent* GetMesh() const;
}
FORCEINLINE USkeletalMeshComponent* ACharacter::GetMesh() const { return Mesh; } //<- And one without elaborated type specifier