C++ Weapon class code not compiling

I’ve created a weapon class for an FPS game, when i try to compile it, the compiler says that the class AWeapon is not defined. Also it says that the name before :: but be a class or a namespace.
This is the code of the .h file:

UCLASS()
class WEAPONESSENTIALS_API AWeapon : public AActor
{
	GENERATED_BODY()
public:
	UFUNCTION()
	AActor(const FPostConstructInitializeProperties& PCIP);

	UFUNCTION()
	void Fire();

	UFUNCTION()
	void Istant_Fire();

	UPROPERTY(EditDefaultOnly, Category = Config)
	FWeapondata WeaponConfig;

	UPROPERTY(EditDefaultOnly, BlueprintReadWrite, Category = Config)
	TEnumAsByte<EWeaponProjectile::ProjectileType> ProjectileType;

	UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Collision)
	TSubObject<UBoxComponent> CollisionComp;

	UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Config)
	TSubobjectPtr<USkeletalMeshComponent> WeaponMesh;	
};

This is the code of the .cpp file:

AWeapon::AActor(const class FPostConstructInitializeProperties& PCIP)
	: Super(PCIP)
{
	
	CollisionComp = PCIP.CreateDefaultSubobject<UBoxComponent>(this, TEXT("Collision"));
	 = CollisionComp;

	WeaponMesh = PCIP.CreateDefaultSubObject<USkeletalMeshComponent>(this, TEXT("WeaponMesh"))
	WeaponMesh->AttachTo();
}

void AWeapon::Fire()
{

}

void AWeapon::Istant_Fire()
{

}

have you included “weapon.h”

yes i did include it. It’s strange cause the syntax should be fine but something is missing…

And what about generated header? Did you include it as well?

(#include “Weapon.generated.h” in header of your Weapon class)

You said your engine version is but the code up there uses FPostConstructInitializeProperties& PCIP, which as been deprecated since 4.6.

So either you copy pasted this class or your under a older version of UE4 than indicated?

Also is your project named WEAPONESSENTIALS ?

So, my guess is you copy pasted a class from this tutorial : [Tutorial] Weapon Essentials C++ Series - C++ - Unreal Engine Forums

?

I am not sure where you are getting your code from but it looks like its from an old version of UE4.

Here is pretty much the same thing but inline with .5:

[Weapon.cpp]

#include "AH476822.h"
#include "Weapon.h"

AWeapon::AWeapon()
{
	PrimaryActorTick.bCanEverTick = true;
    CollisionComp = CreateDefaultSubobject<UBoxComponent>( TEXT("Collider") );
    SetRootComponent( CollisionComp );
    
    WeaponMesh = CreateDefaultSubobject<USkeletalMeshComponent>( TEXT("Mesh") );
    WeaponMesh->SetupAttachment(  );
}

void AWeapon::BeginPlay()
{
	Super::BeginPlay();
	
}

void AWeapon::Tick( float DeltaTime )
{
	Super::Tick( DeltaTime );

}

void AWeapon::Fire( )
{
    
}

void AWeapon::InstantFire( )
{
    
}

[Weapon.h]

#pragma once

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

USTRUCT(BlueprintType)
struct FWeaponData
{    
    GENERATED_USTRUCT_BODY( )
    
    UPROPERTY( )
    float FireRate;

    UPROPERTY( )
    AActor *LastDamaged;
    
    UPROPERTY( )
    ACharacter *Owner;
    
    UPROPERTY( )
    int DamageDoneThisRound;
};

UENUM(BlueprintType)
enum class EWeaponProjectile : uint8
{
    WP_Instant,
    WP_Rocket,
    WP_Grenade,
    WP_Bounce,
};


UCLASS()
class AH476822_API AWeapon : public AActor
{
	GENERATED_BODY()
    
public:
	AWeapon();
	virtual void BeginPlay() override;
	virtual void Tick( float DeltaSeconds ) override;
    
    UFUNCTION()
     void Fire();
 
     UFUNCTION()
     void InstantFire();
 
     UPROPERTY(EditDefaultsOnly, Category = Config)
     FWeaponData WeaponConfig;
 
     UPROPERTY(EditDefaultsOnly, BlueprintReadWrite, Category = Config)
     TEnumAsByte<EWeaponProjectile> ProjectileType;
 
     UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Collision)
     UBoxComponent *CollisionComp;
 
     UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Config)
     USkeletalMeshComponent *WeaponMesh;    	
};

I filled in a few things that were missing, such as the struct and enum.