CCChatServerApp :pubic CWinapp请问程序中的 extern CCChatServerApp theApp 是什么意思?

解决方案 »

  1.   

    extern CCChatServerApp theApp声明一个全局的变量theApp, 其类型为CCChatServerApp。
      

  2.   

    extern 是个定义全局变量的关键字,这条语句的意思是定义应用程序的对象
      

  3.   

    声明全局外部变量,在你的项目的某个cpp文件中有CCCharServerApp的定义,即
    CCCharServerApp theApp;
    此时有些编程者为了调用方便,会在对应的.h文件中使用extern CC...声明,作用是
    在其他文件中如果需要调用theApp对象,不必拘泥于调用:AfxGetApp(),而只需
    #include "xxx.h"
    直接使用 theApp 即可。
    ---------------------------
    例如:
    CXX::func()
    {
        theApp.XXXMember();
    }