473,770 Members | 1,645 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

question regarding header files

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

Jul 23 '05 #1
3 1349
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

Jul 23 '05 #2
si************* *@rediffmail.co m 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
Jul 23 '05 #3
<si************ **@rediffmail.c om> 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.
Jul 23 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
2308
by: da Vinci | last post by:
Hello. First off, I am not sure of the exact jargon used, so I will ask a question regarding it. Then on to my other question. When you use things like cout and cin from the iostream header file, what are those called? Is cout and cin functions? What is the proper term for them a command listed in a header file? Or is it just a "command"?
13
3796
by: J. Campbell | last post by:
I'm wanting to output a text header file in front of the data portion of an output file. However when I use "\n" or "endl" as end of line, it just puts a 0x0a in the file(which is non-printing)...in Windows you need the (0x0d 0x0a) pair, if you want a new-line in a text editor. What's the correct way to get this 2-byte sequence into a file? Thanks #include <iostream>
2
360
by: Rakesh | last post by:
Hi, I was writing this C++ program wherein I used an include statement like - #include <iostream.h> I was told by my co-worker that this form of including a file is deprecated and should not be used, instead it ought to be something like
8
1376
by: Paminu | last post by:
I am trying to split my program in different parts. I have a file called mainfile.c that contains the main() function, some global variables and a few other functions. I then have a file called mainfile.h that contains some structs and a list of the functions that are used in mainfile.c I am then trying to make another file called my_func.c that contains some other functions that when called will update some of the global variables
1
3384
by: William F. Zachmann | last post by:
I am working on a project converting a DLL originally written in C++ using Visual Studio 97 accessing a SQL 6.5 data base to VS.Net 2003 and SQL Server 2000. I would very much appreciate any suggestions and/or references to good sources for information about issues I am likely to encounter along the way. My immediate issue, however, is that after opening the old project and accepting the conversion to VS2003, a build fails with five...
4
1454
by: noone | last post by:
Hi. I've got a fella working for me who is trying to convince me to change our coding standards to using separate .h and .cc files for definitions and implementations. I know this is a perfectly valid way of doing things but in my mind it is kind of quirky. Here's why. The first reason I'd resist deals with the simplicity of makefiles. When including most code from headers where classes are protected by #ifdef blocks the makefile...
2
3800
by: somenath | last post by:
Hi All, I have one question regarding the alignment of pointer returned by malloc. In K&R2 page number 186 one union is used to enforce the alignment as mentioned bellow. typedef long Align; union header { struct {
2
7377
by: jason | last post by:
Hello, I have a question regarding type definitions. I usually put them in header files. But I recently came over several discussions on the www. And now I'm not to sure anymore if they go in .c file or in the header files ? What would be the correct way ? Thank you.
54
3621
by: shuisheng | last post by:
Dear All, I am always confused in using constants in multiple files. For global constants, I got some clues from http://msdn.microsoft.com/en-us/library/0d45ty2d(VS.80).aspx So in header file writing: const double PI = 3.14; Every time using it, include the header file.
0
9432
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10059
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10008
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9873
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7420
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5454
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3974
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3578
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2822
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.