Hi guys,
the same error occurs for me even though I have overwitten the == operator.
To visualise what I’ve done so far here are some code snippets:
I’ve defined the struct within its own .H file:
USTRUCT()
struct FInventoryItem
{
GENERATED_USTRUCT_BODY()
UPROPERTY()
AActor* aItemActor;
UPROPERTY()
FText ftDescription;
FInventoryItem()
{
aItemActor = NULL;
ftDescription = NSLOCTEXT("test_english", "PickupText", "PickupText");
}
bool operator == (const FInventoryItem rhs)
{
if (aItemActor == rhs.aItemActor && ftDescription.EqualTo(rhs.ftDescription))
{
return true;
}
else return false;
}
};
Within a saperate class header I’ve defined an array which contains these Items:
TArray<FInventoryItem> arrInventory;
As soon as I call (within my .CPP):
arrInventory.Contains(AnotherFInventoryItem);
I get the compiler error :
binary '==' : no operator found which takes a left-hand operand of type 'const FInventoryItem' (or there is no acceptable conversion)
as well as:
could be 'bool FInventoryItem::operator ==(const FInventoryItem)'
or 'bool operator ==(const FDialogueContextMapping &,const FDialogueContextMapping &)'
or 'bool operator ==(const FDialogueContext &,const FDialogueContext &)'
...
So the compiler knows about my overwritten method but doesn’t use it. Any idea what I am missing?