The compiler does not recognize UPROPERTY. Since UPROPERTY is not a native C++ class. Something needs to tell the compiler how to handle that class. I am not sure how you went about creating this custom class but I am going to assume you simply added a new .CPP and . h file to your project.
You don’t want to do it that way, exciude those filef from your project then delete them. Lauch the UE4 editor. Once inside the UE4 editor click “file”. From the drop down select “add code to project”. It will then ask you to select a parent class, I would recommend selecting “UObject” based on what you are trying to do. Then it will ask you to name the class, so call it what ever you want.
Doing it this way, the editor will add all necessary files behind the scene so that the compiler knows how to read and understand teh custom UE4 classes.
OK, here’s my recommendation for anyone that’s just trying to create a generic C++ class to be used as a data structure.
UE4 has a reflection system that lets you decorate your various variables and functions with UPROPERTY and UFUNCTION. Plain-Jane classes can’t use this reflection system as the base requirement is that you inherit from UObject.
So the easiest way forward is instead of creating a flat class with no inheritance, inherit from UObject. The 2 caveats to note here are:
You won’t be able to set custom constructor parameters (use an init function instead and pass your parameters post object creation).
Instead of using new/delete c++ operators, you’ll need to instantiate UObject’s properly with NewObject.