Questions for Working With C++

I think you only need to include two things in the header file:

  1. The generated.h file (only if you have defined UCLASSes, USTRUCTs, or UENUMs).
  2. The header of any parent class of classes defined in the file

If it’s not one of the cases above, and you have a property in your header whose type hasn’t been included yet, you can do what’s called forward declaration. Like this:

class UMaterialInterface* Material;
or
void SetMyMaterial(class UMaterialInterface* NewMaterial);
you could also do one forward declaration for the whole file by putting it outside any class declarations, like:
class UMaterialInterface;

Forward declaration is telling the compiler that it should treat UMaterialInterface as a class, even though it hasn’t been included yet.

Keep as many of your #includes as possible in the cpp file instead of the header. It improved compile times.

1 Like

Im pretty sure the *.generated.h applies to the Unreal’ reflection system. Which is required for plethora of reasons.

You have 666 views, and I have to make it 667 so I can keep you out of trouble, so I would study one more thing (one more view) is the way unreal handles classes and all the other stuff such as uproperty tags and similar things so you don’t get a headake :smile: it’s called unreal C++ + plus plus api code and you would be getting lots and lots of → -> → components and load on pointer to some functions.