Making a UCLASS

When coding with C++, you can have your own code that compiles and runs as native C++ code, with appropriate calls to new and delete to create and destroy your custom objects. Native C++ code is perfectly acceptable in your UE4 project as long as your new and delete calls are appropriately paired so that no leaks are present in your C++ code.

You can, however, also declare custom C++ classes, which behave like UE4 classes, by declaring your custom C++ objects as UCLASS. UCLASS use UE4’s Smart Pointers and memory management routines for allocation and deallocation according to Smart Pointer rules, can be loaded and read by the UE4 Editor, and can optionally be accessed from Blueprints

_

UE4 generates and manages a significant amount of code for your custom UCLASS. This code is generated as a result of the use of the UE4 macros such as UPROPERTY, UFUNCTION, and the UCLASS macro itself. The generated code is put into UserProfile.generated.h.
You must #include the UCLASSNAME.generated.h file with the UCLASSNAME.h file for compilation to succeed. Without including the UCLASSNAME.generated.h file, compilation would fail. The UCLASSNAME.generated.h file must be included as the last #include in
the list of #include in UCLASSNAME.h.

A UCLASS can be marked as follows:


1. Blueprintable: This means that you want to be able to construct a Blueprint
from the Class Viewer inside the UE4 Editor.

2. BlueprintType: Using this keyword implies that the UCLASS is usable as
a variable from another Blueprint. You can create Blueprint variables from
the Variables group in the left-hand panel of any Blueprint’s EventGraph. Any UCLASS that have BlueprintType specified can be added as variables to your Blueprint class diagram’s list of variables.