C++ Unreal Engine 4 ERROR C4458. Please help.

Hi!

you have a class member named “item”:

	UPROPERTY(EditAnywhere, BlueprintReadWrite)
		TSubclassOf<class AItem> item;

and you also have a function parameter named “item”:

	bool operator==(const FInventoryItem& item) const <----- ERROR HERE
	{
		if (itemId == item.itemId)
			return true;
		else return false;
	}

You code is actually correct and the error you are getting is technically not an error but a warning. However, it is good practice to have your code compile without warnings so Unreal has the compiler configured to treat warnings as errors so you are forced to deal with them. The warning is that the “item” variable you use as function parameter hides the class member “item” because it has the same name. Just name the function parameter something else like “otherItem”. It is also common for overloaded comparison operators to simply call the identifier on the right “rhs”.

6 Likes