Including .h with correct path


Just a simple question… How do I correctly include header files? I need to know this for my multiplayer shooter game, as my visual studio project can’t seem to access the header file I need.

So… The header file I need is called WeaponBase.h and is located at “/Public/Weapons/Base/WeaponBase.h”. How would I accomplish to include this header in my character.cpp?

Thanks in advance :slight_smile:


Supposing this folder structure:



So my weapon is under Weapons and my Character under player respecting the private/public folder hierarchy, this is the include I would add in my ShooterCharacter.cpp to be able to reach the weapon code:

#include "Weapons/ShooterWeapon.h"

PS .- Consider forward declaration for header files (as long as you don’t operate with the class).

I apologize for delayed response and thank you for a great answer! I was thinking this was the way to go, like using “Weapons/ShooterWeapon.h” instead of “ShooterWeapon.h” but I wasn’t completely sure, and I’m happy you confirmed it for me. I’ve been doing this recently and I’ve had much more success in coding with c++ now, thanks again :slight_smile:

Now, if the issue is resolved, mark it as resolved clicking on the green tick bellow my answer score.