# Right-hand operator overloading

**URL:** <https://forums.unrealengine.com/t/right-hand-operator-overloading/452118>\
**Category:** Character & Animation\
**Tags:** tarray, compare, unreal-engine, pointer, question, CPP\
**Created:** [July 12, 2019, 6:48am UTC](https://forums.unrealengine.com/t/right-hand-operator-overloading/452118 "2019-07-12T06:48:32Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Atijaf](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Atijaf](https://forums.unrealengine.com/u/Atijaf)\
**Post date:** [July 12, 2019, 6:48am UTC](https://forums.unrealengine.com/t/right-hand-operator-overloading/452118/1 "2019-07-12T06:48:32Z")

</div>

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;

- 

```
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();
	}
};
```

---

<div class="post-metadata">

**Author:** ![HarryHighDef](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@HarryHighDef](https://forums.unrealengine.com/u/HarryHighDef)\
**Post date:** [July 12, 2019, 9:26am UTC](https://forums.unrealengine.com/t/right-hand-operator-overloading/452118/2 "2019-07-12T09:26:40Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Przemek2222](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Przemek2222](https://forums.unrealengine.com/u/Przemek2222)\
**Post date:** [July 13, 2019, 7:02pm UTC](https://forums.unrealengine.com/t/right-hand-operator-overloading/452118/3 "2019-07-13T19:02:37Z")

</div>

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.
