Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > question regarding header files

Reply
Thread Tools

question regarding header files

 
 
siddharth_jain_1@rediffmail.com
Guest
Posts: n/a
 
      05-16-2005
Hello,

1) what do header files contain exactly?
Do they just contain the variable declarations, typedefs and
function prototypes?

2) taking the example of iostream.h: it contains the prototyoes of
various functions. which file has the actual code of these functions?


3) If I build my own header file (header.h) which includes some
function prototypes and I have another file (program.c) that has the
actual code for these functions, when I go to use those in another
program. If i #include "myheader.h" in my new file (project.c) will it
then know to look in code.c for the function?

4) Could someone please guide me to a good link from where I can read
about the usage of header files/


Thanks,

Siddharth Jain

 
Reply With Quote
 
 
 
 
Victor Bazarov
Guest
Posts: n/a
 
      05-16-2005
http://www.velocityreviews.com/forums/(E-Mail Removed) wrote:
> 1) what do header files contain exactly?
> Do they just contain the variable declarations, typedefs and
> function prototypes?


They contain anything that you deem necessary to share between compilation
units. Headers are usually created to be included in more than one module
to be compiled.

> 2) taking the example of iostream.h:


BTW, there is no such header. I will assume we're talking <iostream>.
Also, you should know that _standard_ headers are not necessarily files.
Just so we're clear on that.

> it contains the prototyoes of
> various functions. which file has the actual code of these functions?


That's specific to the implementation. If the compiler vendor supplied
you with the source code to their implementation of the Standard library,
then the actual code is there somewhere. If the vendor didn't provide
the source code, then the actual code is on the vendor's computers and
you only get to see the declarations.

> 3) If I build my own header file (header.h) which includes some
> function prototypes and I have another file (program.c) that has the
> actual code for these functions, when I go to use those in another
> program. If i #include "myheader.h" in my new file (project.c) will it
> then know to look in code.c for the function?


No, it won't. You will need to compile 'code.c' separately and add it to
the command line of the linker so that the object code is linked into the
final program.

> 4) Could someone please guide me to a good link from where I can read
> about the usage of header files/


www.google.com

V
 
Reply With Quote
 
 
 
 
eeykay@gmail.com
Guest
Posts: n/a
 
      05-16-2005
STLs usaully provides implementation also in the header files. Your
point 1. is correct. Regarding your point 3, I assume code.c includes
"myheader.h". So, the compiler compiles it to an code.obj file, which
the linker uses to link with your project.obj, to produce the final
program. You should look for how c++ program compiles to generate an
output for more in-depth details. Writing your own makefile will also
help understanding these things.
-EK

 
Reply With Quote
 
osmium
Guest
Posts: n/a
 
      05-16-2005
<(E-Mail Removed)> wrote:


> 1) what do header files contain exactly?
> Do they just contain the variable declarations, typedefs and
> function prototypes?


They also usually contain the actual code (the function definition) for
templated functions.


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Header files with "header.h" or <header.h> ?? mlt C++ 2 01-31-2009 02:54 PM
regarding header files Windows.h and process.h raghu C Programming 1 01-24-2007 01:34 PM
regarding header files Windows.h and process.h raghu C Programming 0 01-24-2007 01:17 PM
UNIX header files to Windows header files anand.ba@gmail.com C Programming 3 05-01-2006 03:57 PM
Header files included in header files John Smith C Programming 18 07-24-2004 04:55 AM



Advertisments