Can't use UBoxComponent to create collision

I got issue when i want to create a box collision by UBoxComponent.
There is my code. Thanks for any help!
Weapon.h
// Fill out your copyright notice in the Description page of Project Settings.

#pragma once

#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "Weapon.generated.h"

UCLASS()
class FPSGAME_API AWeapon : public AActor
{
	GENERATED_UCLASS_BODY()

	void WeaponFire();
	void WeaponReload();

	UPROPERTY(VisibleDefaultsOnly, Category = Config)
	UBoxComponent* CollisionComp;
	
	UPROPERTY(VisibleDefaultsOnly, Category = Mesh)
	USkeletalMeshComponent* Mesh1P;

};

Weapon.cpp
// Fill out your copyright notice in the Description page of Project Settings.

#include "Weapon/Weapon.h"


// Sets default values
AWeapon::AWeapon(const FObjectInitializer& ObjectInitializer) :Super(ObjectInitializer)
{
	CollisionComp = ObjectInitializer.CreateDefaultSubobject<UBoxComponent>(this, TEXT("CollisionComp"));
	RootComponent = CollisionComp;
	Mesh1P = ObjectInitializer.CreateDefaultSubobject<USkeletalMeshComponent>(this, TEXT("Mesh1P"));
	Mesh1P->SetupAttachment(CollisionComp);
	
}

void AWeapon::WeaponFire()
{

}

void AWeapon::WeaponReload()
{

}

Error:

1>D:\Program Files\Epic Games\Unreal Project\FPSGame\Source\FPSGame\Public\Weapon/Weapon.h(18): error C2143: syntax error: missing ';' before '*'
1>D:\Program Files\Epic Games\Unreal Project\FPSGame\Source\FPSGame\Public\Weapon/Weapon.h(18): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>D:\Program Files\Epic Games\Unreal Project\FPSGame\Source\FPSGame\Public\Weapon/Weapon.h(18): error C2238: unexpected token(s) preceding ';'
1>D:\Program Files\Epic Games\Unreal Project\FPSGame\Source\FPSGame\Private\Weapon\Weapon.cpp(9): error C2065: 'CollisionComp': undeclared identifier
1>D:\Program Files\Epic Games\Unreal Project\FPSGame\Source\FPSGame\Private\Weapon\Weapon.cpp(9): error C2065: 'UBoxComponent': undeclared identifier
1>D:\Program Files\Epic Games\Unreal Project\FPSGame\Source\FPSGame\Private\Weapon\Weapon.cpp(9): error C2672: 'FObjectInitializer::CreateDefaultSubobject': no matching overloaded function found
1>D:\Program Files\Epic Games\Unreal Project\FPSGame\Source\FPSGame\Private\Weapon\Weapon.cpp(9): error C2974: 'FObjectInitializer::CreateDefaultSubobject': invalid template argument for 'TReturnType', type expected
1>D:\Program Files\Epic Games\UE_4.16\Engine\Source\Runtime\CoreUObject\Public\UObject/UObjectGlobals.h(819): note: see declaration of 'FObjectInitializer::CreateDefaultSubobject'
1>D:\Program Files\Epic Games\Unreal Project\FPSGame\Source\FPSGame\Private\Weapon\Weapon.cpp(10): error C2065: 'CollisionComp': undeclared identifier
1>D:\Program Files\Epic Games\Unreal Project\FPSGame\Source\FPSGame\Private\Weapon\Weapon.cpp(12): error C2065: 'CollisionComp': undeclared identifier
1>ERROR : UBT error : Failed to produce item: D:\Program Files\Epic Games\Unreal Project\FPSGame\Binaries\Win64\UE4Editor-FPSGame-4331.dll
1>Total build time: 19.30 seconds (Local executor: 0.00 seconds)
1>D:\Program Files\Microsoft Visual Studio\2017\Community\Common7\IDE\VC\VCTargets\Microsoft.MakeFile.Targets(44,5): error MSB3075: The command ""D:\Program Files\Epic Games\UE_4.16\Engine\Build\BatchFiles\Build.bat" FPSGameEditor Win64 Development "D:\Program Files\Epic Games\Unreal Project\FPSGame\FPSGame.uproject" -waitmutex" exited with code 5. Please verify that you have sufficient rights to run this command.

Include "Components/BoxComponent.h", add this include and it’ll work.

Thanks a lot, it’s working.

When I add that include, I get multiple namespace errors. How can I fix that?

Hard to tell. please show the error messages

Sorry for not writing sooner.

All I did was create a new actor class, and try to add a UBoxComponent to it (following a tutorial I found), but it said UBoxComponent is undefined (despite following the tutorial exactly, although the tutorial might be a bit dated). After adding the Components/UBoxComponent.h include, I get namespace erros.

I copy-pasted the code below, and attached screenshots of the errors before and after adding the Components/UBoxComponent.h.

// Fill out your copyright notice in the Description page of Project Settings.

#pragma once

#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "Pickup.generated.h"
#include "Components/BoxComponent.h"

UCLASS()
class PP_API APickup : public AActor
{
	GENERATED_BODY()
	
public:	
	// Sets default values for this actor's properties
	APickup();

	UBoxComponent* PickupBox;

protected:
	// Called when the game starts or when spawned
	virtual void BeginPlay() override;

public:	
	// Called every frame
	virtual void Tick(float DeltaTime) override;

	
	
};

Thank you for your time.

One of your errors is “#include found after .generated.h file …”. Basically your “.generated.h” include has to always be the last.

i think use class keyword infront of UBoxComponent* PickupBox;