This is probably a stupid question but how can I link
multiple header files using just 1 header file include
in my projects instead of including each and every
one seperately?
mainHead1.h, mainHead2.h, mainHead3.h
#include "mainHead1.h" //I want to be able to include head2 and head3 with it.
int main()
{
return 0;
}
[Solved] Header files
Moderator: Coders of Rage
- zodiac976
- Chaos Rift Regular
- Posts: 156
- Joined: Thu Jun 18, 2009 10:03 am
- Current Project: Booklet & Text RPG
- Favorite Gaming Platforms: PC, PS3, PSP
- Programming Language of Choice: C++
- Location: AL
- Contact:
[Solved] Header files
Last edited by zodiac976 on Sun Jun 28, 2009 5:46 pm, edited 1 time in total.
- zodiac976
- Chaos Rift Regular
- Posts: 156
- Joined: Thu Jun 18, 2009 10:03 am
- Current Project: Booklet & Text RPG
- Favorite Gaming Platforms: PC, PS3, PSP
- Programming Language of Choice: C++
- Location: AL
- Contact:
Re: Header files
Never mind I figured it out by just storing all includes
in a header file then use that header file to link all
other header files.
in a header file then use that header file to link all
other header files.
- MarauderIIC
- Respected Programmer
- Posts: 3406
- Joined: Sat Jul 10, 2004 3:05 pm
- Location: Maryland, USA
Re: [Solved] Header files
I think you would be better of #include-ing every one individually, that way your files are guaranteed to only link to what they need. If you need an include in an include (like you're using strings in your class definition), then you need to #include <string> using namespace std; inside that header. But still, you want to keep includes in every file to the minimum required.
I realized the moment I fell into the fissure that the book would not be destroyed as I had planned.
- dandymcgee
- ES Beta Backer
- Posts: 4709
- Joined: Tue Apr 29, 2008 3:24 pm
- Current Project: https://github.com/dbechrd/RicoTech
- Favorite Gaming Platforms: NES, Sega Genesis, PS2, PC
- Programming Language of Choice: C
- Location: San Francisco
- Contact:
Re: [Solved] Header files
Just as a side note: The last big project I was working on, I ended up somehow creating a circular dependency of header files (~5 different classes depended on each other). You'll want to avoid that at all costs as it can cause some pretty bad headaches.MarauderIIC wrote:I think you would be better of #include-ing every one individually, that way your files are guaranteed to only link to what they need. If you need an include in an include (like you're using strings in your class definition), then you need to #include <string> using namespace std; inside that header. But still, you want to keep includes in every file to the minimum required.

Falco Girgis wrote:It is imperative that I can broadcast my narcissistic commit strings to the Twitter! Tweet Tweet, bitches!
- zodiac976
- Chaos Rift Regular
- Posts: 156
- Joined: Thu Jun 18, 2009 10:03 am
- Current Project: Booklet & Text RPG
- Favorite Gaming Platforms: PC, PS3, PSP
- Programming Language of Choice: C++
- Location: AL
- Contact:
Re: [Solved] Header files
So I am better off using the header files seperately?
- dandymcgee
- ES Beta Backer
- Posts: 4709
- Joined: Tue Apr 29, 2008 3:24 pm
- Current Project: https://github.com/dbechrd/RicoTech
- Favorite Gaming Platforms: NES, Sega Genesis, PS2, PC
- Programming Language of Choice: C
- Location: San Francisco
- Contact:
Re: [Solved] Header files
Yes, include them one per line only where you need them.zodiac976 wrote:So I am better off using the header files seperately?
Falco Girgis wrote:It is imperative that I can broadcast my narcissistic commit strings to the Twitter! Tweet Tweet, bitches!