lhlc

导航

MFC中全局变量的定义及使用

一、在应用程序类中定义

  需继承 CWinApp 类;

  CTestApp *app = (CTestApp *)AfxGetApp(); //生成指向应用程序类的指针 

二、用静态变量和静态函数实现

public: 
  static int x; //全局变量 
  static int time; //全局变量 
  static int f(int y); //全局函数 


int CPublic::x = 0; //初始化全局变量 
int CPublic::time; //定义全局变量


转载自:

https://www.cnblogs.com/lvdongjie/p/4504467.html

posted on 2020-02-27 12:38  lhlc  阅读(485)  评论(0编辑  收藏  举报