Benefit of Source File's??

X

Xoomer

What is the benefit using some source files instead of all in one
file?

Is that has something to do with make, build, quick compile or
something etc? can you explain please.. thanks
 
I

Ian Collins

Xoomer said:
What is the benefit using some source files instead of all in one
file?

Is that has something to do with make, build, quick compile or
something etc? can you explain please.. thanks
Ever tried to put a 100K line application being worked on by ten people
in one file?
 
N

Neelesh Bodas

What is the benefit using some source files instead of all in one
file?

Is that has something to do with make, build, quick compile or
something etc? can you explain please.. thanks

make, build, quick compile - all make sense only when one
"understands" the structure of the code that has been written. And the
dividing project into logical/physical units is precisely to
understand the structure of the code. Look it in this way:

-Why write functions? why not write the whole code inside "main"
function only?
- why create classes? why not write in procedural style?
- why write in high level langauge? why not write in assembly?

Though individual questions can be answered separately, the theme
essentially remains the same: It makes coder's and maintainer's life
much easier.

-N
 
?

=?ISO-8859-1?Q?Erik_Wikstr=F6m?=

What is the benefit using some source files instead of all in one
file?

Is that has something to do with make, build, quick compile or
something etc? can you explain please.. thanks

If you have a program with millions lines of code, let's say about 1.5
MLOC and an average of 15 characters per line, you'll end up with a file
size of 21 MB. Have you ever thought about how hard it would be to
actually find something in the file? Files are nice logical units to
organise you code in.

Here's another problem, if you have it all in one file you'd have to
recompile the whole project even if all you did was to change change a
letter printed on the screen. IF you have multiple files you only have
to recompile those that changed, and those that depend on the changed files.

BTW, make does not have anything to do with C++ per se, it's just a tool
to simplify keeping track of changes so you don't recompile files that
don't need to.
 
J

Joe Greer

What is the benefit using some source files instead of all in one
file?

Is that has something to do with make, build, quick compile or
something etc? can you explain please.. thanks

If you actually design your projects, then you can put together the class
specification/public interface together and hand it off to another team who
is going to use it. They can then develop using the interface while you
merrily finish development of the class. At the end, you may have to give
them a new header with all your private data, but in the meantime, everyone
has been able to make progress.

The other reason has to do with compile times, though with sophisticated
enough build systems could probably get the needed info from intermediate
files, so that isn't an amazingly good reason.

And, the most important reason.... history. In the olden days, separate
header files was the easiest way to allow separate compilation.

joe
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top