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.

Example:

// MyApp.h
class CMyApp : public CWinApp
{
public:
  CMyApp();

  static int g_nMyVariable;      // declaration
  static void g_MyFunction();    // declaration
  ...
  etc
  ...
};
// 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...

 



Comments

  • EKoHY NkY RYtU

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

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

    Reply
  • vetqI Ibm TMZI

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

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

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

Top White Papers and Webcasts

  • Learn How A Global Entertainment Company Saw a 448% ROI Every business today uses software to manage systems, deliver products, and empower employees to do their jobs. But software inevitably breaks, and when it does, businesses lose money -- in the form of dissatisfied customers, missed SLAs or lost productivity. PagerDuty, an operations performance platform, solves this problem by helping operations engineers and developers more effectively manage and resolve incidents across a company's global operations. …

  • Today's agile organizations pose operations teams with a tremendous challenge: to deploy new releases to production immediately after development and testing is completed. To ensure that applications are deployed successfully, an automatic and transparent process is required. We refer to this process as Zero Touch Deployment™. This white paper reviews two approaches to Zero Touch Deployment--a script-based solution and a release automation platform. The article discusses how each can solve the key …

Most Popular Programming Stories

More for Developers

RSS Feeds