Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

3dmodelerguy

classes question

This topic is 5232 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

is there a benfit from keeping the class seperate from the member function statement? [edited by - 3dmodelerguy on March 20, 2004 11:29:34 AM]

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
Other? What was/were the other(s) then?

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
hmm...
If you mean is there any benefit from putting the class declarations in .h files and implementations to .cpp files then, yes. Here are two coming to my mind first:
- It''s cleaner (and, after all, the way it''s generally done)
- Reduces compiling time considerably (implementations are compiled once only)

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
I don''t know. I''ve never tried C# but I''d guess it has a different class-importing system (couldn''t find any more suitable word now). In C++, when you #include the headers to cpp files, the headers are just copied to them and then compiled. If you have the implementations in headers they''ll get compiled too -- every time you compile the cpp file. In C# there might be some sort of import statement (?) or some other system which doesn''t include the implementations to every source file...

Man, this post is a mess...

Share this post


Link to post
Share on other sites
You should, however, weigh the increased compile times against the maintenance times involved in keeping header and implementation files separate.

Share this post


Link to post
Share on other sites
If you use VC++ as an IDE, you can hop straight to the method in like 2 clicks anyway.

Another use of keeping them separate is that you can distribute the headrers with a compiled lib, then you''re not giving your source code away.

Share this post


Link to post
Share on other sites
Rubbish.

There is no benefit in the header/implementation file dichotomy. It is simply a limitation of C and C++''s outdated compilation mechanisms. It could be resolved with a multi-pass compilation and the definition of a per-platform ABI, but the Standards Committee won''t do that, citing the overwhelming volume of existing code that would either be broken or need to be rebuilt.

One day, those limitations will catch up to the languages and (finally) remove them from first contention.

Share this post


Link to post
Share on other sites
quote:
Original post by Oluseyi
Rubbish.

There is no benefit in the header/implementation file dichotomy.


On the contrary, there is a HUGE benefit to doing this. Not least because if you keep implementation out of the header file, it''s SO much easier to see at a glance what a class does by looking at its interface. If I want to know what a class does, I don''t want to scan down the header file 100s of line and try to pick out the member functions, I want to glance at the interface and see how to use it.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!