I got the solution.
The blueprint “Inventory” property was set to null. I just needed to change it to the default instance of “UInventory” instantiated at contructor of the C++ class.
APerson_Character::APerson_Character()
{
//
// Some code...
//
// Instantiate the new object of UInventory.
Inventory = CreateDefaultSubobject<UInventory>(FName("Inventory"));
}
At the details tab, in editor, I needed to click to set the default value of “Inventory” property, like that
And of course needed to change the UPROPERTY like that
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly)
UInventory* Inventory;