Right-hand operator overloading

I am receiving the error "binary ‘==’: no operator found which takes a right-hand operand of type ‘ABasicCharacter’ (or there is no acceptable conversion)

I’ve tried all possibly ways I can think of to overload this operator, but have been unsuccessful. I assume I am misunderstanding something simple. Here is some simplified example code. Please ignore that the data it holds does not make sense as well as the function names.

The error occurs in the function “TestFunction”

This was originally working when my TArray was

TArray<DataClass>* DataArray, 
//but then I changed it to
 TArray<DataClass*>* DataArray
//due to some changes in my coding.  (Pointer to TArray of objects   TO   Pointer to TArray of pointers)
  • class ABasicCharacter
    {
    public:
    TArray<DataClass*>* DataArray;
    int UniqueCode;

      int GetUniqueCode_ABasicCharacterClass() const
      {
      	return UniqueCode;
      }
    
      void TestFunction()
      {
      	bool Outcome = DataArray->FindByKey(*this);
      	//Error here, FindByKey is not recognizing my overloaded function.
      }
    

    };

class DataClass
{
public:
	int UniqueCode;

	int GetUniqueCode_DataClass() const
	{
		return UniqueCode;
	}

	inline bool operator==(const ABasicCharacter& RHS) const
	{
		return this->GetUniqueCode_DataClass() == RHS.GetUniqueCode_ABasicCharacterClass();
	}
};

Is your DataClass a UClass?
Have you considered making it a Struct/UStruct.
Have you tried using the unreal FORCEINLINE macro instead of inline?

Hello,

friend bool operator==(const ABasicCharacter& RHS) { return this->GetUniqueCode_DataClass() == RHS.GetUniqueCode_ABasicCharacterClass(); }

Untested. Let me know in comment if it doesn’t work.