Jump to content
  • Advertisement

Archived

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

EvilKind

Is it good practise to put more than one class in a source file?

This topic is 5489 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 it good practise to put more than one class in a source file? I personally have mainly used the OO language Eiffel along with BON and so far have always used a class for a source file. Now seeing more then one class in a C++ source file has surprise me. I can see that it''s fewer files to look at but is this good practise?

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
I truely believe it isn''t because I like to give my classes descriptive names

Share this post


Link to post
Share on other sites
generally, no (IMHO of course)... but sometimes if i have several small related classes i put them into one header & source file (i.e. CTextureManager, CTexture, and the various helper structs) because anything that uses one will use all of them.

just my 2 cents

[edited by - krez on July 8, 2003 7:39:09 PM]

Share this post


Link to post
Share on other sites
In general, put them in their own files. The two cases you'll probably have more than one class per .h/.cpp pair are

1) A large class with a helper class (A resource manager is a good example, maybe a linked list or tree with nodes as a seperate object, etc.)

2) A bunch of small, related classes (think < functional > from the C++ library)

The idea is to have one "idea" per .h/.cpp pair.

[edited by - Way Walker on July 8, 2003 12:56:39 AM]

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!