Jump to content
  • Advertisement


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


programming with multiples .cpp

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

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!