Making an instance with class keyword and without it

hi. in battery collector tutorials what are the differences between TSubclassOf(class APIckup) and TSubclassOf(APickup)or some other cases like this in general? they both seem to work well.

Putting the class keyword before a type name is a foward declaration of a type that a file is so far unaware of. It’s like saying to the compiler, “APickup is a class type and that’s all you need to know right now.”

It’s a technique commonly used to avoid placing include statements inside of a header file because they can sometimes lead to circular dependencies and compilation failures, as well as increasing compile times.

Another way to make a forward delcaration is by simply stating

class APickup;

or if it’s a struct type

struct FMyStruct;

After which you can refer to the type normally.

Ideally you want to try to use forward declarations in header files as much as possible and only include additional headers inside of your source files.