views:

26

answers:

2

How do you include header files from top-level and sub-directories in c++?

A: 

From the include directory? I guess you meant like:

#include <dir\header.h>

Ruel
@Ruel Yes, using #include keyword.
xor
if the header file is in the include directory use greater than and less than symbols (<>), if it's on the project directory or solution, use double quotations ("").
Ruel
I'm begging you, please don't use backslashes... I know you think you're *never* going to port your application... but you might one day, and it will be a huge pain in the arse to change all your backslashed includes to forward slashes. VS will gladly use forward slashes, e.g. #include <dir/header.h>
ceretullis
+3  A: 

#include "sub/some_header.h"

#include "../other_header.h"

mr. Vachovsky
+1 for forward slashes ;)
ceretullis