Free2Code
The majority of forums are now only available as archives, which means posting/editing is disabled.

The Anything and Everything forum is still open.
 
Time: 2013-05-25, 04:57pm
c++ header files
Subject: c++ header files  ·  Posted: 2003-06-12, 01:08am
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??
 
  Reply to this ·  Post link ·  Top
Subject: c++ header file  ·  Posted: 2003-06-12, 01:13am
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??
 
  Reply to this ·  Post link ·  Top
Subject: Re: c++ header files  ·  Posted: 2003-06-17, 06:35am
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..

 
  Reply to this ·  Post link ·  Top
Subject: header file  ·  Posted: 2003-06-20, 02:25am
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
 
  Reply to this ·  Post link ·  Top
Subject: Re: c++ header files  ·  Posted: 2003-10-02, 07:26am
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. <> then the compiler looks in a set of standard directories for the file, if surrounded by inverter commas (i.e. " " then it looks in the directory you are working from. (you can include other files eg. dot.cpp in the same way). The easiest way to use a hearder then is to just write the C\C++ code for it, save it as a blah.h file and cut and paste it into the directory where the rest of your .h files are.
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.
 
  Reply to this ·  Post link ·  Top
Subject: cpp files vs header file  ·  Posted: 2003-10-23, 02:27pm
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
 
  Reply to this ·  Post link ·  Top
Subject: Re: cpp files vs header file  ·  Posted: 2003-10-23, 04:56pm
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
 
  Reply to this ·  Post link ·  Top
Subject: Re: c++ header files  ·  Posted: 2003-10-23, 04:57pm
Rank: ? (614)
Member #: 9832
Just testing something...

Chaos reigns within - Reflect, repent, and reboot - Order shall return
 
  Reply to this ·  Post link ·  Top
Subject: Re: c++ header files  ·  Posted: 2003-10-23, 04:58pm
Rank: ? (614)
Member #: 9832
Just testing something...

Chaos reigns within - Reflect, repent, and reboot - Order shall return
 
  Reply to this ·  Post link ·  Top
Subject: Can We Define  ·  Posted: 2003-11-05, 01:07pm
Rank: Unregistered
Hi,

Can we run and define loops and arrays in header files like in some class?

Regards,
Bilgrami.
smurtaza81pk@yahoo.com
 
  Reply to this ·  Post link ·  Top
Subject: networking  ·  Posted: 2004-01-30, 05:11pm
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
 
  Reply to this ·  Post link ·  Top
Subject: c++ header file (mysql.h)  ·  Posted: 2004-04-04, 05:09am
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
 
  Reply to this ·  Post link ·  Top

Pages: 1

Please login or register to post a reply.

Penguino AVR

Want to learn about robotics or microcontrollers?
Check out the Penguino AVR from our friends at
Icy Labs