Globals in MFC

MFC class framework makes possible to work easily with global variables and functions. Let's declare a static member variable or function in the CWinApp derived class. It is accessible from all classes.


// MyApp.h
class CMyApp : public CWinApp

  static int g_nMyVariable;      // declaration
  static void g_MyFunction();    // declaration
// MyApp.cpp
int CMyApp::g_nMyVariable = NULL;     // definition & initialization
void CMyApp::g_MyFunction()        // definition

Now the variable and the function are accessible through the syntax CMyApp::g_nMyVariable or CMyApp::g_MyFunction from any other class...



  • EKoHY NkY RYtU

    Posted by wfAahmllrb on 11/15/2012 08:45pm

    buy soma carisoprodol grapefruit juice - can you really buy soma online

  • vetqI Ibm TMZI

    Posted by cVNExPQHwR on 11/14/2012 01:57am

    carisoprodol 350 mg carisoprodol 350 mg erowid - somanabolic muscle maximizer side effects

Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • As the mobile enterprise marketplace expands and customer needs grow more diverse, Samsung recognizes that solution partners and developers play an essential role by continually innovating to meet their customers' needs. Samsung works to provide these developers and partners with the latest tools and resources needed to create these solutions. Read this program guide to learn how the Samsung Enterprise Alliance Program provides partners and developers with Samsung enterprise software development kits (SDKs) …

  • Thanks to the Internet of Things (IoT), physical assets are turning into participants in real-time global digital markets. The countless types of assets around us will become as easily indexed, searched and traded as any online commodity. While some industries will be tougher to transform than others – those with physical limitations, such as manufacturing, will be harder to digitize – untold economic opportunities exist for growth and advancement. Our research shows this will create a new "Economy …

Most Popular Programming Stories

More for Developers

RSS Feeds

Thanks for your registration, follow us on our social networks to keep up-to-date