Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[C++] Moving classes to header files
#8
Eosian Wrote:Ultimately it's likely stylistic preference and comfortable organizational structure and nothing more.
Nope. The way Russt describes is the standard way of doing things (class interface in header, class implementation in cpp). Doing it that way allows you to change the implementation of a method and then only that cpp file will have be recompiled. If you put the implementation into the header, then any cpp that includes the header will have to be recompiled when any part of the implementation changes. Of course, you still have to recompile all cpp files that depend on that header file if you add private methods to the class or something. To get around that, you can use the PIMPL (pointer to implementation) idiom. And no matter what, templates have to be implemented in the header and you lose the ability to avoid recompilation like you do with normal classes.

Yes, having separate header and implementation files is redudant. Yes, C++ is hideously complex. No, there isn't any less sucky widely used language that lets you have OO and compilation to native code. I've heard about D, but I've never given it a try.
Reply


Messages In This Thread
[C++] Moving classes to header files - by Dusk - 2010-05-07, 09:34 PM
[C++] Moving classes to header files - by Eos - 2010-05-07, 09:41 PM
[C++] Moving classes to header files - by Eos - 2010-05-08, 12:40 AM
[C++] Moving classes to header files - by Russt - 2010-05-09, 12:18 AM
[C++] Moving classes to header files - by Eos - 2010-05-09, 12:25 AM
[C++] Moving classes to header files - by Spaz - 2010-05-09, 01:08 AM
[C++] Moving classes to header files - by Eos - 2010-05-09, 01:13 AM
[C++] Moving classes to header files - by Russt - 2010-05-20, 09:55 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)