How to create an object on a component

Hello. Bit of a noob here so apologies if this seems like a dumb question!

I’ve got a function where I’m trying to add a new InventoryItem object to my Inventory ActorComponent, but I keep getting these errors where I’m trying to create the NewObject.

Error C2027 use of undefined type ‘UInventoryItem’
Error C3861 ‘StaticClass’: identifier not found

In the .h

    	UPROPERTY(EditAnywhere, Instanced)
    	TArray<UInventoryItem*> Inventory;
    
    	UFUNCTION(BlueprintCallable)
    	void AddInventoryItem(TSubclassOf<UInventoryItem> ItemClassToAdd);

In the .cpp

void UInventoryComponent::AddInventoryItem(TSubclassOf<UInventoryItem> ItemClassToAdd)
{
	UInventoryItem* NewItem;
		
	NewItem = NewObject<UInventoryItem>(this, ItemClassToAdd);


}

Thanks!