How to tell which header file you need?

One thing I’ve been struggling with is determining which header file is needed to use certain functions. In this lecture and others the instructor appears to be pulling them from memory. If we do not know at all what is the best method for determining which header file is necessary? As an example here how would one go about determining that “AIController.h” was the header file necessary to include?

You need to include headers for the types you are using.

This line

which has OwnerComp.GetAIOwner()->GetPawn(), OwnerComp.GetAIOwner() returns an AAIController*. In order to be able to call GetPawn() on it, the compiler needs to know what that is, that it’s a function that returns APawn*. i.e. it needs the definition of the AAIController class and to do that you include the header that defines it which you can find via the docs

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.

Privacy & Terms