Jump to content
  • Advertisement
Sign in to follow this  
Samurai Jack

Wierd encapsulation design

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

Greetings! I was wondering, instead of using external variables over .H and .CPP files, I could just use some kind of static pointers. 1. Previous idea: -File::"test.h" contains: class CVideoDevice : {...} CVideoDevice* GetVideoDevice(void); //maybe this file would contain also extern CVideoDevice* g_pDevice; //i don't like that -File::"test.cpp" contains: CVideoDevice* g_pDevice; //GetVideoDevice Returns this [end] I do not like to have my variables laying arround like this in some libraries, what about this: CVideoDevice** GetVideoDevice(void) { static CVideoDevice* l_VideoDevice = NULL; return &l_VideoDevice; } - Is there any other way? Any suggestions?

Share this post


Link to post
Share on other sites
Advertisement
Check out the Singleton design pattern - I think that will probably suit you.

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!