PDA

View Full Version : Access a Header File


orcfan32
05-23-2005, 11:39 PM
How can I access a .H (header file) from C++?

<P ID="signature">. . . .
. . . .
. . . . . (Real signature in progress.....)</P>

Kuikorosu
05-23-2005, 11:40 PM
> How can I access a .H (header file) from C++?

#include "Mypenis.h"

<P ID="signature"><hr>
YES, LADIES AND GENTLEMEN
THE FUTURE IS HERE
AND IT'S EVEN LAMER THAN
YOU THOUGHT POSSIBLE. (http://www.asciiartfarts.comAsciiartfarts</A>)</P>

Slicer S. V.
05-24-2005, 05:36 AM
> #include "Mypenis.h"

actually, shouldn't it be more like:

<pre> #include < urDick.h > </pre>

<P ID="signature">http://img.photobucket.com/albums/v247/SlicerSV/misc/Searthsig.png
My Work In Progress</P>

Disch
05-24-2005, 05:41 AM
< > are typically used with stanard headers and stuff that's part of whatever API you're using, or other system stuff. Whereas quotes are typically used with files specific to this program. Although, I think they're both 100% interchangable.

<P ID="signature"></P>

Slicer S. V.
05-24-2005, 05:52 AM
> < > are typically used with stanard headers and stuff that's
> part of whatever API you're using, or other system stuff.
> Whereas quotes are typically used with files specific to
> this program. Although, I think they're both 100%
> interchangable.

ah. see, the tutorial i am using didn't say anything about this. it just told me to use <> when including a header...

<P ID="signature">http://img.photobucket.com/albums/v247/SlicerSV/misc/Searthsig.png
My Work In Progress</P>

MooglyGuy
05-24-2005, 10:38 AM
> Although, I think they're both 100%
> interchangable.

They're not. A standards-compliant compiler will, as far as I know, look in the specified includes/ directory for things included with < > and in the same directory as the .c or .cpp file for things included with " ", and never the twain shall meet.

<P ID="signature"></P>

orcfan32
05-24-2005, 12:25 PM
I know how to access it now, but what use is a header file? Can I call functions from it?

<P ID="signature">. . . .
. . . .
. . . . . (Real signature in progress.....)</P>

Kuikorosu
05-24-2005, 01:04 PM
> They're not. A standards-compliant compiler will, as far as
> I know, look in the specified includes/ directory for things
> included with < > and in the same directory as the .c or
> .cpp file for things included with " ", and never the twain
> shall meet.

A good general rule of thumb might be, "If you have to type the .h, then use quotes, if not, use angle brackets." If you use .h in angle brackets (#include < iostream.h >) a good compiler will bitch at you for using depreciated headers.

<P ID="signature"><hr>
YES, LADIES AND GENTLEMEN
THE FUTURE IS HERE
AND IT'S EVEN LAMER THAN
YOU THOUGHT POSSIBLE. (http://www.asciiartfarts.comAsciiartfarts</A>)</P>

pipes
05-24-2005, 03:18 PM
> I know how to access it now, but what use is a header file?
> Can I call functions from it?

Its were you declair all your shit like libs and stuff, and brings everything togeather.

<P ID="signature">-----------------------------------------
The pipes clangor all the http://www.zophar.net/personal/pipes/clangor.jpgtime</a>!</P>

Disch
05-24-2005, 03:59 PM
C headers are not depreciated. The greatest thing about C++ is that it includes all of C

<P ID="signature"></P>

Disch
05-24-2005, 04:01 PM
> I know how to access it now, but what use is a header file?
> Can I call functions from it?

Header files are mainly for defining structs / classes / functions which you want several c/.cpp files to have access to. If you declare functions just in a .cpp file, other .cpp files in your program won't have access to the function. However if you put the function prototype in a header, any cpp file which has that header #included will be able to call the function. But only one cpp file needs to have the actual function body.

<P ID="signature"></P>

Disch
05-24-2005, 04:05 PM
This is what I used to think actually. It makes the most sense to me, too. But I read on SDLs site somewhere that you should using quotes when #including the SDL header because it's the most compatible or something. So I tried swapping out < > and "" as an experiment and the compiler didn't seem to care (well, VS anyway -- but it wouldn't suprise me in the least if that's not standards compliant)

<P ID="signature"></P>

Isildur
05-24-2005, 07:02 PM
> So I tried
> swapping out < > and "" as an experiment and the compiler
> didn't seem to care (well, VS anyway -- but it wouldn't
> suprise me in the least if that's not standards compliant)
>

Yeah, I've never noticed it making a difference in VS. Perhaps it might affect what takes precedence if you have two or more different header files of the same name, in the prog directory, in the standard VC include directory, and/or in any extra include directory specified in the project properties.

<P ID="signature"><center>
<a href=http://1001insomniacnights.com><img src=http://pages.nyu.edu/~jc73/misc/1k1IN.gif border=0>
1k1IN:</a><font color=#903030> A Dark Comedy About 2 Roomates</font></center></P>