here u have built a header file which have all declaration and .cpp file for defination but if we will use this outside world the we have to only include .h file but my question is that how to jump header file to defination file. there is no one way.we are useing only header file and in header file no one other file (defination file).and in header file we will write in declaration file....the way we are using is reverse so can u explain how to link.I am not getting this thing in my program also it works but not getting myself.....
--- In [email protected], "David Hamill" <[EMAIL PROTECTED]> wrote: > > > how to creat a header file in which i can define my own > > functions and > > can call that header file through including it viz > > #include<stdio.h>,#include<conio.h> > > Any C-language file can be included as a header file, e.g.: > > #include "my_file.h" > > Note that you have to use quotes "..." rather than > angle-brackets <...>. The latter are only used for library > files. And the .h extension is just a convention. > > Header files generally contain function prototypes, not > function definitions. The usual convention is to do > something like this: > > ------------- > thing.h: > ------------- > #ifndef THING_H > #define THING_H 1 > > #define CONSTANT 42 > > int func(int a); > > #endif > ------------- > > ------------- > thing.c: > ------------- > #include <string.h> > #include "thing.h" > > int func(int a) > { > return a + CONSTANT; > } > ------------- > > (Sorry for any typos/bugs; I haven't tried compiling this.) > > The purpose of #defin'ing THING_H is to prevent thing.h > being included multiple times. This can easily happen in a > large project where header files include other header files, > and it can lead to problems. > > The purpose of #includ'ing the .h file in the .c file is > that it can catch inconsistencies between them, e.g. a > function prototype that differs from the function > definition. > > It's a good idea to think of the .h file as providing an > interface to the outside world; any implementation details > should go in the corresponding .c file. But different people > have different views on what should go where. :-) > > David >
