Archived

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

LordReaper

programming with multiples .cpp

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