Expected an identifier

I think the line where you’re getting the error should just be

InventoryList.Add(GetOwner());  

but that will add it to a UInventoryList that you create on the line before, and I believe will be destroyed on the line after.

You need a reference to a UInventoryList (probably in the player) to add the item to. You’ll also need it in some other functions there like ItemInReach

So I am trying to build a basic inventory system and improve on it once I have the main function of it down pat.
So I have a Item.h which is added to items that need to be added to inventory, and Inventory.h for actors who will have an inventory (in this case my first person player). I’m new with C++ and also learning as I go, so bear with my rookie mistakes!

Item.h

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

#pragma once

#include "Engine.h"
#include "CoreMinimal.h"
#include "Components/ActorComponent.h"
#include "Item.generated.h"

#define OUT

UCLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) )
class LIFE_API UItem : public UActorComponent
{
	GENERATED_BODY()

public:	
	// Sets default values for this component's properties
	UItem();

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

public:	
	// Called every frame
	virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override;

private:

	UPROPERTY(EditAnywhere)
		int StackSize = 1;

	UPROPERTY(EditAnywhere)
		int MaxStackSize = 100;
	
	//player reach radius for items
	float Reach = 150.f;

	//add item to inventory
	void AddItem();

	//Setup Input componenet
	UInputComponent* Input = nullptr;

	void SetupInputComponent();

	//is item in reach
	bool ItemInReach();
	
};

Item.cpp

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


#include "Item.h"
#include "Inventory.h"




// Sets default values for this component's properties
UItem::UItem()
{
	// Set this component to be initialized when the game starts, and to be ticked every frame.  You can turn these features
	// off to improve performance if you don't need them.
	PrimaryComponentTick.bCanEverTick = true;

	// ...
}


// Called when the game starts
void UItem::BeginPlay()
{
	Super::BeginPlay();
	SetupInputComponent();
	

	// ...
}

void UItem::SetupInputComponent()
{
	Input = GetOwner()->FindComponentByClass<UInputComponent>();
	if (Input)
	{
		Input->BindAction("Action", IE_Pressed, this, &UItem::AddItem);
	}
}

// Called every frame
void UItem::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction)
{
	Super::TickComponent(DeltaTime, TickType, ThisTickFunction);

	if (ItemInReach() == true)
	{
		AddItem();
	}

}

bool UItem::ItemInReach()
{
	FVector ItemLocation = GetOwner()->GetActorLocation();
	FVector PlayerLocation;
	FVector DistanceBetween = PlayerLocation - ItemLocation;
	FRotator PlayerRotation;
	GetWorld()->GetFirstPlayerController()->GetPlayerViewPoint(OUT PlayerLocation, OUT PlayerRotation);
	float RealDistance = DistanceBetween.Size();

	if (RealDistance <= Reach)
	{
		return true;
	}
	return UItem::ItemInReach();
}


void UItem::AddItem()
{
	UInventory InventoryList();
    UInventory.InventoryList.Add(AActor *GetOwner());  // THIS IS WHERE I'M GETTING THE ERROR
}

 Inventory.h

// Fill out your copyright notice in the Description page of Project Settings.
    
    #pragma once
    
    #include "CoreMinimal.h"
    #include "Components/ActorComponent.h"
    #include "Inventory.generated.h"
    
    
    UCLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) )
    class LIFE_API UInventory : public UActorComponent
    {
    	GENERATED_BODY()
    
    public:	
    	// Sets default values for this component's properties
    	UInventory();
    
    protected:
    	// Called when the game starts
    	virtual void BeginPlay() override;
    
    public:	
    	// Called every frame
    	virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override;
    
    	TArray<AActor*> InventoryList;
    	
    	int ItemIndex;
    
    private:
    
    };

Sorry if that is too much I’m new so I don’t know where to look exactly, I’ve done many google searches but can’t figure this one out. Edit: One of my headers is included in the second block of code. should be three blocks