Advertisement Jump to content
Sign in to follow this  
Samurai Jack

Wierd encapsulation design

This topic is 4931 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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!