I have something like this declared in static library
USTRUCT()
struct FItem
{
GENERATED_USTRUCT_BODY()
EItemType ItemName;//enum
float Number;
FItem(EItemType ThisItemType,float ThisNumber) : ItemName(ThisItemType)
{
CategoryName = GetItemCategory(ThisItemType);
Number = ThisNumber;
}
};
in AActor derived class in .h
FItem N4 = FItem(EItemType::VE_BronzeIngot, 5);
FItem N1 = FItem(EItemType::VE_EmptyItem,5);
FItem N2 = FItem(EItemType::VE_Beer, 5);
FItem N3 = FItem(EItemType::VE_ClayBrick, 5);
TArray<FItem*> Npointer;
in .cpp
Npointer.Add(&N1);
Npointer.Add(&N2);
Npointer.Add(&N3);
Npointer.Add(&N4);
And my question is how to use HeapSort in this case because this
Npointer.HeapSort([](const FItem* A, const FItem* B) {return A->ItemName < B->ItemName; });
and several other variation didnt work … I am pretty new with c++ so many things are confusing for me …
basicaly I figureout that I would need pas pointer as reference and I dont know how … combination FItem*& didnt work … because its already pointer … at least I think …