Hi,
Apologies if this has already been asked before, but I couldn’t find an answer that made sense to me.
My specific question is: Is there a portable way to have a collection of object that do not derive from UObject? And the more general question is should all c++ classes inherit from UObject (or any derived classes of UObject). If not, what are some guidelines around when you should/shouldn’t derive from UObject?
As background, I am playing around with a hex board game, and wanted to store the hex coordinates in a class: HexCoordinate. I initially made this a basic c++ class (not inheriting from anything) but then I wanted to be able to store several coordinates in a container, e.g. TArray. But when I try and do this it complains
Error C2039 'StaticClass': is not a member of 'TArray<HexCoordinate,FDefaultAllocator>
I can’t see much documentation about this, but I thought it was that TArray can only have objects that inherit from UObject.
But if I convert it to a UObject, I have to use pointers and use NewObject and can’t use constructors and … Which seems really annoying when I just want to create a lightweight object to store a few uint32’s. Is there a way around having to use this?
Hope this makes sense, thanks in advance