• Advertisement

Archived

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

programming with multiples .cpp

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

hi, guys! I have 2 .cpp''s and 2 .h''s in my project. One is ddraw.cpp and ddraw.h and the other set is main.cpp and main.h. I have the HWND hWnd variable in my main.cpp, but a function in my CDDraw class within the ddraw.cpp file needs to acess it. How I setup the hWnd in order it works perfectly?

Share this post


Link to post
Share on other sites
Advertisement
Well it is bad programming practice, but you could add a line like:

extern HWND hWnd;

in your main.h and then include main.h in your ddraw.cpp

That should get it working But if you plan on working on an OO paradigm you probably want to look into a Singleton to manage your global data. I believe there is an article somewhere on Gamedev or Flipcode about Singleton data managers.

Share this post


Link to post
Share on other sites

  • Advertisement