Subj : Re: Not using .cpp files when programming... To : comp.programming From : David Date : Wed Jul 20 2005 01:40 am On Tue, 19 Jul 2005 17:32:25 UTC, Eric Fortier wrote: > Hi all, > > When I'm writing a C++ class, I've built up this habit of putting all my code > right in the .H header file with the class definition. I'm not doing that with > 100% of my code, of course, only when I make a utility class (CRC, string, > loader, etc). > > I know this can't be good practice, but as of yet I never had any problems. I > find it a lot easier to maintain too, and I don't have to keep adding .CPP to > the projects I work on; I just add the header and I'm done. > > In the interest of searching for non-existent problems, can anyone tell me what > is wrong with this? ;) > > Thanks a lot, > > --Eric Eric, I take it you generally program with just one CPP file (the main one) then. Your method can work for some projects, but how would it work for larger projects? For instance, if you are creating a "string utility class" would you put that all in one file? Then how do you reuse that utility in multiple CPP files? Say that you have lots of little projects (like in Unix) made of your utilities, how then would you make a somewhat larger project that required the combination of two or three projects that all included some of the same utilities? Would you end up reworking the source at all? As for managing multiple CPP files, what is the big deal? Does that take a bit more time than adding the include files? Also, as the size of your H files increases with the code in it, each resulting main CPP compile will take just a bit longer. A very large project would be easier in smaller chunks that are linked together. A good organization of H files won't cause the world to be recompiled. David .