Message-Id: <199910201103.OAA00495@ankara.Foo.COM> From: "S. M. Halloran" Organization: User RFC 822- and 1123-compliant To: djgpp AT delorie DOT com Date: Wed, 20 Oct 1999 15:10:28 +0200 MIME-Version: 1.0 Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7BIT Subject: Re: help with .h files In-reply-to: X-mailer: Pegasus Mail for Win32 (v3.12) Reply-To: djgpp AT delorie DOT com X-Mailing-List: djgpp AT delorie DOT com X-Unsubscribes-To: listserv AT delorie DOT com Precedence: bulk Section 4.3 (Chap. 4) of _The C++ Programming Language_ (2nd Ed.) by Bjarne Stroustrup explains what header files are to be used for, and this applies in standard C as well as C++ to a great extent. Pp. 113-4 say the following: A header file may contain: Example -------------------------- -------------------------- 1. type definitions struct point { int x, y; } 2. templates template class V { /* ... */ } 3. function declarations int strlen(const char *); 4. inline function definitions inline char get() { return *p++; } 5. data declarations extern int a; 6. constant definitions const float pi=3.141593; 7. enumerations enum bool { false, true }; 8. name declarations class Matrix; 9. include directives #include 10. macro definitions #define Case break;case 11. comments /* a comment */ Headers should never contain: 1. ordinary function definitions char get() { return *p++; } 2. data definitions int a; 3. constant array definitions const tbl[] = { /* .... */ }; One thing that is only really barely touched upon is whether to use a single header file for multiple sources, or supply one header file for each source, or to use a combination. On 20 Oct 99, James Vasile was found to have commented thusly: > Header files are places to define structures and macros, for the most > part. They get included (#include "header.h") at the top of the .cpp > files that include the actual code you're writing. At least, this is > how it is in c. I've not done much cpp, and perhaps .h files have > functions in cpp that they don't have in c. > > Peace, > -J > > > On Thu, 22 Jul 1999 17:09:35 GMT, manfred DOT heumann AT uni-bielefeld DOT de > (Manni Heumann) wrote: > > >In article <37CECA25 AT MailAndNews DOT com>, "Psycho_Circus" wrote: > >>Is there any help or documentation on the .h files that come with the djgpp > >>c++ compiler? I'm new to c++ and do not understand exactly what the .h > >>files > >>do. For example, I never would have figures out what cout or cin is w/o the > >>c++ book I got. How do I know what functions are in the .h files and what > >>they do? Thanks in advance for any help. > >> > >>- Me > >> > > > >Keep on reading! Don't stop after the first chapter. Mitch Halloran Research (Bio)chemist Duzen Laboratories Group Ankara TURKEY