include Macro

Hi guys.

Everytime i create a class header like
1
2
3
4
5
6
7
8
9
10
11
#IFNDEF BLAH_H
#DEFINE BLAH_H

#include "foo"
#include "bar"

class Blah{

};

#ENDIF 


And if i add it like #include "blah.h", i also add foo and bar classes and see the functions they provide. Is there a way to prevent this.

Thanks in advance.
Last edited on
Not a good way, no. #include is a glorified copy/paste -- it's like you're copy/pasting the header into the file that includes it.

The best way is to simply not include foo/bar in the header.
If i need to use foo and bar classes' functions inside Blah, how else i can add them? An example maybe.

Sorry if i misunderstood.
Last edited on
If you don't need the full class you can forward declare them and avoid the include.

If you do need the full class then you'll have to include them. And I guess just live with the fact that they'll also be included in anything that includes your header. =/
So simply put, there is no way :)

Thanks for all the answers anyway. Helped a lot.
Topic archived. No new replies allowed.