header files............?

Mar 8, 2009 at 11:36am
Can header files have function definition........is it necessary that it must only have function prototypes.......
Mar 8, 2009 at 12:03pm
The can, but it's usually preferable that they don't.
If two files that are supposed to be linked together include a header that has definitions, there's a chance the linker will produce a duplicate definition error. I can't at this time remember the exact conditions that are required for this to happen.

There are, however, times when it's necessary to put the definition in the header. This is the case with template functions.
Mar 9, 2009 at 4:57am
Can you explain what exactly a header file is......what is its purpose.......
Mar 9, 2009 at 5:37am
Inline functions are defined within a header. There is nothing wrong with that. To avoid duplicate definition linker errors you simply surround the contents of the headers with some kind of guard mechanism to prevent that.
Mar 9, 2009 at 10:34am
Header files are used to declare symbols which are compiled separately so you can use them. That's why you don't have function bodies in the header (except in cases already mentioned)
Mar 10, 2009 at 1:31pm
Can you get me a good link where i 'll understand about headers completely.............even i m searching for one.......
Mar 10, 2009 at 1:49pm
Topic archived. No new replies allowed.