Make every header self-contained
The header includes its base class and forward declares member pointer types.
Pickup.hcpp
#pragma once
#include "GameFramework/Actor.h"
#include "Pickup.generated.h"
class UItemDefinition;
class USphereComponent;
UCLASS()
class ACTIONGAME_API APickup final : public AActor
{
GENERATED_BODY()
private:
UPROPERTY(VisibleAnywhere)
TObjectPtr<USphereComponent> CollisionComponent;
UPROPERTY(EditDefaultsOnly)
TObjectPtr<UItemDefinition> ItemDefinition;
};- Why
- The header cannot accidentally depend on a unity build or precompiled header to provide a missing definition.
- Costs
- Forward declarations stop working when a complete type is required, such as a by-value member or some template instantiations.
- Instead
- Include the exact defining header when the compiler needs the type layout.
CoreMinimal.his convenient for game headers, but it does not replace feature-specific includes.

