TArray Find() C2678 error even with operator overload '=='.
I am trying to create an inventory based system using two USTRUCTS FAlchemyItem (FAI) and FAlchemyFluid (FAF). The FAlchemyItem contains and FAlchemyFluid and is generally used as a transporter for the FAF as multiple different FAI's can have the same FAF.
The inventory is a TArray. There is a Find() in the processor when attempting to add the 'item' to the inventory.
(Appologies for the '.' I'm using them to keep the error log neat.)
I have tried multiple different ways of overloading the operator and have to no avail been able to solve this. At this point I have no idea what the error even is. Could id be that the comparision is trying to compare to a nullptr?
Use of the Find():
Please let me know if I didn't provide enough information. I will respond ASAP. Thank you for your help
asked Apr 16 '18 at 08:45 PM in C++ Programming
After a long amount of time and thinking on this reply
made by Arty-McLabin I came to the conclusion that I would have to not use the predefined functions. By using the for loop
For some reason, the prior way I iterated through the string and the way it derived the equivalency operator statement just would not work with my code. So instead I did it on my own and I have had no issues now. The operator had no issues as j.muller RFG speculated.
Thank you both of you, with your help I was able to find a proper solution.
answered Apr 19 '18 at 09:08 PM
The compiler says
He can't compare the two: (const FAlchemyFluid, FAlchemyFluid *const )
Which is pretty logical, because you cannot compare a pointer and an object. I am not sure which line has caused this error, so just go to this line and try to give it a non pointer input instead.
edit:. you probably want to learn the difference of "const T*" and "T* const".in your case, you create a pointer to const object, rather than const pointer to object.
I think you have to dereference
BTW I personally prefer to write const always right of the thing it makes constant, because it`s more consistent:
answered Apr 18 '18 at 10:43 AM
Follow this question
Once you sign in you will be able to subscribe for any updates here