What are the required member functions for using TArrays?
I have a C++ class I am using quite extensively that inherits from nothing (chose none in the GUI). This class is just a data class and will not be placed in the world at any point. At some point I placed this class in a TArray and attempted to use TArray::RemoveSingle. This led to the following error:
Error C2678 binary '==': no operator found which takes a left-hand operand of type 'const Quad' (or there is no acceptable conversion) Array.h 992
I assumed this means "You don't have a == operator. How do I find something?" So I overloaded operator== and I was right. But this got me thinking, there are probably other scenarios that my class is missing that I am not thinking of. Do I need a < operator for sorting? Do I need a toString? Since my class doesn't inherit from anything, I do not have virtual functions to override. How can I know what functions I should make to ensure future classes behave as expected and don't throw unexpected compiler errors?
asked Aug 24 '16 at 10:40 PM in C++ Programming
Yes, you need to make all operators because compiler don't know what to do with data in the class if you don't describe it. And yes oyu need < for sorting.
Also if you want class that just holds data i recomand you to make struct insted of class, this way it will be compatible with reflection system (if you use USTRUCT() and UPROPERTY()) making things a lot easier in editor
Follow this question
Once you sign in you will be able to subscribe for any updates here