Re: header files
From: Francis Glassborow (francis_at_robinton.demon.co.uk)
Date: 04/05/04
- Next message: Leor Zolman: "Re: 2D array of pointers"
- Previous message: Francis Glassborow: "Re: couple of general questions"
- In reply to: mike ttoouli: "Re: header files"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Mon, 5 Apr 2004 20:58:43 +0100
In message <c4s9o6$k0i$1@newsg3.svr.pol.co.uk>, mike ttoouli
<mttoouli@yahoo.com> writes
>hi jeffc, sorry I wasn't being very clear.
>
>It was never my intention to create one big file - lots separate files, each
>being used by one another. All the code could just be written in .h files,
>and used by other .h files by including them (#include "filename.h" - can
>this be done with cpp files?).
>
>This would lead to the problem of including the same header file in more
>than one place in a large program, but by enclosing the code in each header
>file using:
>
>#ifndef FILENAME_H
>#define FILENAME_H
>..code...
>#endif
>
>then this would ensure that the header file is added only the first time it
>is encountered in a program, as after that FILENAME_H is defined.
Then your program will have to consist of a single monolithic
translation unit. The job of header files is to mediate between a
program written as multiple TU + one or more libraries.
One mamoth disadvantage of the monolithic approach is that every change
anywhere requires complete recompilation.
>
>well i think that makes sense. I've implemented a fairly large program only
>using header files, and I couldn't really see the point of .cpp files at
>all.
Sorry, but I do not believe you (I am sure you think you have buyt a
fairly large program would consist of tens of thousands of lines of
code.) If you cannot see the point of .cpp files I suspect you do not
understand the basics of organising work the way C and C++ have been
designed for.
-- Francis Glassborow ACCU Author of 'You Can Do It!' see http://www.spellen.org/youcandoit For project ideas and contributions: http://www.spellen.org/youcandoit/projects
- Next message: Leor Zolman: "Re: 2D array of pointers"
- Previous message: Francis Glassborow: "Re: couple of general questions"
- In reply to: mike ttoouli: "Re: header files"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|