I was simply wondering, what is the difference between an empty c++ class and a UObject class? I really need to know because I’ll be using one of these as containers for a bunch of variables, structs and enums, and I need to know if there’s any crucial difference between the two classes, like I know objects handles garbage collection.
As you already seem to know, pure C++ class is not managed, you will need to deal with clearing pointers and deleting any pure C++ objects, once created you only one who can delete it and if you lose pointer, then you got memory leak.
As side of that those objects are not supported UE4 reflection system, so you don’t have UClass for it and you can not use it with UPROPERTY(), engine wont’t see it, as well you can not use it with any property editor as engine don’t see varbales either. When you compile C++ code everything lose names, variables and functions are turn in to numeric addresses, lot of things in C++ sometimes have only logical meaning to compilation and only effects way things are compiled, not final CPU code it self, thats why UE4 has reflection system to track the names by classes register themselves in run time by UHT generated code. UE4 also wont know about existence of object of pure C++ classes, thats why garbage collation dont work on them.
Also because it not in reflection system it wont work with most of UE4 APIs. That said UE4 it self use pure C++ classes sometimes, more notable is AssetTypeAction which as information about asset type for editor, and those need to me manually registered on module start.
Worth mention is that there no difference between class and struct, most notable is struct by default is public while class is private and that practically it. Put it in that context, you can use functions in structures with USTRUCT, which can use UPROPERTY() so things can be managed in them by UE4, you wont be bale to use those function in blueprints (or else you do function in UObject class calling stricture function) but you be able to call them in C++. Problem is UE4 reflection system don’t support dynamic allocated structures, it does not track them, but you can use pointers to structure ofcorse outside of UPROPERTY(). So don’t know what you trying to do but it viable alternative
Okay, thanks! This was alot of useful information I think I’ll stick to UObjects instead of empty c++ classes as the majority of them binds functionality to blueprints.