why do I see more than one *.cpp file?

Started by
8 comments, last by YodaTheCoder 22 years, 4 months ago
Why, why, why do people have more than one .cpp file? I thought you were only supposed to have 1!!! whywhywhywhy!?!?!?? like, I see stuff like main.cpp camera.cpp tex.cpp ah! Why does that help? does it even? ..thanks
Advertisement
It helps.

---------------

I finally got it all together...
...and then forgot where I put it.
Is this a trick-question...?
1) No, you''re not "supposed to have 1".
2) It''s good for organization.
3) It helps (re)compile times dramatically with larger projects.

[Resist Windows XP''s Invasive Production Activation Technology!]
Well, big, professional projects have 100s-thousands of lines of code (really big projects can go into several million lines of code). You don''t want to have 500000 lines of code in a single file, would you ? Would be a bit chaotic....

OK, to elaborate:

It is considered "good OOP practice" to declare a class in a .h file and provide the implementation in a .cpp file of the same name. This helps you to navigate the project and find things easily. Also, it means that if you change one .cpp file, the compiler does not have to recompile all the rest of them to get the program running again. FI, with v12 engine, first build takes about 20mins. After that, you change one or two things in one .cpp file and it only takes about 5secs to compile it again. Now imaging all the source was in one file. Hehe, I think u get my drift. Anyway, hope that helps clear things up 4 u.

---------------

I finally got it all together...
...and then forgot where I put it.
so 20 .cpp files is like , all the same file really?
P.S. I started writing that second post right after my first one. Sorry, didn''t notice other replies.

---------------

I finally got it all together...
...and then forgot where I put it.
Yoda: Yeah, sort of.

---------------

I finally got it all together...
...and then forgot where I put it.
www.pokemon.com

This topic is closed to new replies.

Advertisement