Jump to content
  • Advertisement
Sign in to follow this  
frogtag

Class Etiquette

This topic is 3414 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

Advertisement
You can. This would imply to the average reader that there's a specific kind of eyes known as "face eyes", which are distinct from other, non-face kinds of eyes. It's not really that useful, though.

Share this post


Link to post
Share on other sites
I use inner classes regularly. They can used to improve encapsulation.

Their advantage over non-inner classes is that they can access the outer class' private members in many languages (no "friend" relation needed). You can also make the inner class private in the outer class, so it cannot be used outside of the outer class (and it's friends).

I also use forward declared inner classes in C++, in particular with the Pimpl idiom.



// Header file

class Pimpl
{
public:
private:
struct impl_t; // put all private members here
impl_t *impl; // and use them through this pointer
};

// Implementation file
#include <nastyplatformheader.h> // we don't want this in the header file

struct Pimpl::impl_t
{
NastyPlatformSpecificThing thing;
};

Pimpl::Pimpl() : impl(new impl_t)
{
impl->thing = createThing();
}

Pimpl::~Pimpl()
{
delete impl;
}


This has the obvious advantage of not having to include implementation specific header files in our header. You can also have multiple implementations of the same routines using the same header files. For example, you can have a single set of header files for a library that has implementation files for Windows and Linux and let your build system decide which to use.

-Riku




Share this post


Link to post
Share on other sites
Sign in to follow this  

  • 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!