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

  • The open source cloud computing project OpenStack has come a long way since NASA and Rackspace launched it in 2010. Backed by leading technology infrastructure providers including Cisco, Dell, EMC, HP, IBM, Intel, and VMware, OpenStack underpins significant workloads at an increasingly diverse set of organizations, including BWM, CERN, Comcast, eBay, and Wal-Mart. For CIOs engaged in broader programs to win, serve, and retain customers -- and refocus business technology (BT) spend -- a planned and pragmatic …

  • Featuring Doug Kaplan, Director of Customer Success at InfoArmor Live Event Date: October 26, 2016 @ 10 AM PT / 1 PM ET We'll be highlighting InfoArmor, a solution provider for identity protection software, who recently made the move to a cloud contact center to support their advanced threat protection services offered to their large user base in the cloud. Join InfoArmor and Genesys to hear: An insider view of how InfoArmor built a justification and gained consensus to make the move to the cloud Tips on …

Most Popular Programming Stories

More for Developers

RSS Feeds

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