The majority of forums are now only available as archives, which means posting/editing is disabled.
The Anything and Everything forum is still open.
The Anything and Everything forum is still open.
c++ header files
|
|||
|
Rank: Unregistered
|
hi everyone and anyone
i am trying to figure out how does a header file work in c and c++ and then proceed with making my own.... here's what i have discovered till now what i know is that abc.h will contain only declarations and another file may be abc.o or abc.obj or abc.dll will contain definitions of these declarations and u need to include only abc.h to access its functions.... i tried this procedure in TurboC++ compiler but didn't work asked for definitions... i checked out many header files in the compiler and found only declarations..... is my knowledge correct ??? or am i wrong ... how does header file work ... how can i make one ....? help anyone?? |
||
|
|||
|
|||
|
Rank: Unregistered
|
hi
i wrote that subject "c++ header file " anyone may mail me at hollow_dark_man@yahoo.com MY MEASSAGE WAS hi everyone and anyone i am trying to figure out how does a header file work in c and c++ and then proceed with making my own.... here's what i have discovered till now what i know is that abc.h will contain only declarations and another file may be abc.o or abc.obj or abc.dll will contain definitions of these declarations and u need to include only abc.h to access its functions.... i tried this procedure in TurboC++ compiler but didn't work asked for definitions... i checked out many header files in the compiler and found only declarations..... is my knowledge correct ??? or am i wrong ... how does header file work ... how can i make one ....? help anyone?? |
||
|
|||
|
|||
|
Rank: ? (24)
Member #: 2188 |
The header file definitions r right but the implementation of the functions delcared r normally written at a c or cpp file..
|
||
|
|||
|
|||
|
Rank: ? (383)
Member #: 867 |
To make your own header file, you need to include it by writing #include "myheaderfile.h", replacing "myheaderfile.h" with the name of your header file. Nonetheless, you need to enclose it in quotes if you want the path to be relative to your .cpp file.
Just throw your functions in a file and include it as explained above.
This comment is copyright by Dino (http://dino.shiftedphase.com/) and may not be reproduced without written permission of the housing authority, the Senate, the United Nations, my neighbour's dog, the grocer and the guy who just jumped off the bridge
|
||
|
|||
|
|||
|
Rank: Unregistered
|
reply to last caller. A header file is just a piece of C\C++ code, more or less the same as a x.cpp or dot.c file they contain definitions of the things that a programmer uses frequently but which aren't basic C\C++ commands(eg. how to output to a console, how to take the sine or cosine of a number in math.h or cmath etc,) any standard ansi C function you use (eg. getch(),) is probably contained in a header file. When you compile a program the header files are copied into your code before linking as if you wrote it into the code yourself and they make life easier for the beginning programmer as it makes coding easier to understand what you are doing when you don't have to define everything from scratch or use preprocessor directives etc. and saves thye more advanced programmer a lot of time and effort. The directive #include blah.h tells the compiler to look for the blah header file; if blah.h is surrounded by angle brackets (i.e. <>
The .dll, .o etc associated with the headers you have seen are created AFTER compilation, they are not always created and in general their creation is not required for your code to work. i.e. ignore them, they are created if that's what the code in the hearer file dictates. A final point, you should be able to open up your .h files and view the code as if it was any other program you had stored in that directory. |
||
|
|||
|
|||
|
Rank: Unregistered
|
Then are we suppose to include these cpp file in main file...My Project contain 3 cpp file ...how can i link it to my main programme.. else that cpp files says ,undeclared variable .pl advice..
Thanks |
||
|
|||
|
|||
|
Rank: ? (614)
Member #: 9832 |
If you use command line compiler, usually you just compile them together and they will be linked automatically.
For example, if you use borland command line compiler and want to compile and link a.cpp and b.cpp just do this: bcc32 a.cpp b.cpp bcc32 is compile and link command. There is also compile only and link only commands, which are useful if you have a big project with dozens of .cpp files and don't want to compile them all when you change only one. If you use IDE (Visual C++, Borland builder, whatever) they have all kind of project management tools to keep track of your files. With command line compilers, you can use makefiles to organize things, but first experiment with couple of files only.
Chaos reigns within - Reflect, repent, and reboot - Order shall return
|
||
|
|||
|
|||
|
Rank: ? (614)
Member #: 9832 |
Just testing something...
Chaos reigns within - Reflect, repent, and reboot - Order shall return
|
||
|
|||
|
|||
|
Rank: ? (614)
Member #: 9832 |
Just testing something...
Chaos reigns within - Reflect, repent, and reboot - Order shall return
|
||
|
|||
|
|||
|
Rank: Unregistered
|
Hi,
Can we run and define loops and arrays in header files like in some class? Regards, Bilgrami. smurtaza81pk@yahoo.com |
||
|
|||
|
|||
|
Rank: Unregistered
|
We are in urgent need of the following header files
machparam.h netether.h netInet.h netUltra.h netfddi.h sprite.h Our MainID is : vichu_mag@yahoo.co.uk |
||
|
|||
|
|||
|
Rank: Unregistered
|
how is mysql.h header included in a program which is been ran on th e command line i.e using the borland compilier to execute it to connect to a database.
thanks in advance elvis |
||
|
Please login or register to post a reply.
