mescaline wrote:[color=blue]
>
>
> However my question is -- why the prototype.
> So far, if I needed to add extra functionality, I'd use only the
> headers as follows : #include "a_file.cpp" in my main_file.cpp
> The "new" way (for me), is writing #include <a_file.h> in
> main_file.cpp and then using this as a prototype for a_file.cpp which
> actually contains the code. My question is what is gained by adding
> the prototype?[/color]
David has already explained it, but let me show you an example
taken from my current work:
The project consists of aproximately 4400 *.cpp files. Compiling
all of them takes between 1 and 1.5 hour.
If I need to build a new executable, just because of correcting a
bug, what do you think is better:
* having to recompile all of the source code, because all those
*.cpp files are included in one main.cpp and I need to feed
main.cpp to the compiler (takes between 1 and 1.5 hours)
* compiling just the *.cpp file which was fixed and linking all
the individual pieces to form the executable (takes between
10 seconds and a maximum of a few minutes).
Which version would you chosse?
[color=blue]
>
> Also, how do I get this program to run? -- I don't have VC++ only a
> gcc complier
> -- putting the 3 files in one directory and compiling gives the same
> output as stated above[/color]
You need to read your compilers documentation or ask in a newsgroup
dedicted to gcc. But usually it's just:
gcc fileA.cpp fileB.cpp fileC.cpp
and gcc will compiler each of the source files individually and
after that link them to form an executable.
But consult your documentation to look for the details, since I don't
use gcc by myself and typed the above from memory.
--
Karl Heinz Buchegger
kbuchegg@gascad.at