[C++] How to include file in C++...

Hi @MilionX!

I learned C++ a long time ago so I might get some facts here wrong and just wanted to give a heads up, but it shouldn’t be super far off.

Some .h (header) files don’t have the #include and I’ll try to explain why, but first I’ll try to explain why you need to include the .h (header) files.

You will need to include the .h (header) file if a file is trying to use some functions, variables or even declare a class that isn’t defined inside the file. For example, if you wanted to use “DrawDebugPoint” inside a character class, you would need the “#include ‘DrawDegubHelpers.h’” because the “DrawDebugPoint” isn’t defined or declared in the character class or it’s parent classes. Another example would be making a variable of type “ShooterCharacter.” You will also need the .h file of the “ShooterCharacter.”

Some .h (header) files do not have the #include. That is because when you use the #include you are copying all the functions and variables from that .h file into the file that has the #include. (This will happen when packaging your game) This will increase file size and may make the game slower because of all the unnecessary stuff.

So many developers forward declare the variable. For example they use “class ShooterCharater shooterCharacter;” instead of “ShooterCharacter shooterCharacter;” By adding the “class” in front of a variable you are forward declaring so you do not need to use the #include in the .h file, but you will need to in the .cpp file.

Hope this helps! :v: