zoukankan      html  css  js  c++  java
  • error C2065: 'theApp' : undeclared identifier

    解决办法一:
    在你要访问的地方的 .cpp 文件中加入
    extern C***App theApp;

    解决办法二:
    得到指向app的指针
    如 ((C***App *)AfxGetApp())->你的成员变量

    我是在主程序的头文件里添加就可以了:

    // five.h : main header file for the FIVE application
    //

    #if !defined(AFX_FIVE_H__0B197DD2_A92A_4BC8_9B02_88A17EC40DBE__INCLUDED_)
    #define AFX_FIVE_H__0B197DD2_A92A_4BC8_9B02_88A17EC40DBE__INCLUDED_

    #if _MSC_VER > 1000
    #pragma once
    #endif // _MSC_VER > 1000

    #ifndef __AFXWIN_H__
    #error include 'stdafx.h' before including this file for PCH
    #endif

    #include "resource.h" // main symbols

    /////////////////////////////////////////////////////////////////////////////
    // CFiveApp:
    // See five.cpp for the implementation of this class
    //

    class CFiveApp : public CWinApp
    {
    public:
    CFiveApp();

    // Overrides
    // ClassWizard generated virtual function overrides
    //{{AFX_VIRTUAL(CFiveApp)
    public:
    virtual BOOL InitInstance();
    //}}AFX_VIRTUAL

    // Implementation

    //{{AFX_MSG(CFiveApp)
    // NOTE - the ClassWizard will add and remove member functions here.
    // DO NOT EDIT what you see in these blocks of generated code !
    //}}AFX_MSG
    DECLARE_MESSAGE_MAP()
    public:
    CDatabase m_DB;
    };

    extern CFiveApp theApp;
    /////////////////////////////////////////////////////////////////////////////

    //{{AFX_INSERT_LOCATION}}
    // Microsoft Visual C++ will insert additional declarations immediately before the previous line.

    #endif // !defined(AFX_FIVE_H__0B197DD2_A92A_4BC8_9B02_88A17EC40DBE__INCLUDED_)
  • 相关阅读:
    WCF三种通信方式
    Linux发布WebApi
    Supervisor Linux程序进程管理
    Centos安装Mongodb
    本地网址连不上远程mysql问题
    .Net之垃圾回收算法
    .Net之托管堆资源分配
    Centos7+ASP.Net Core 运行
    ASP .Net Core 使用 Dapper 轻型ORM框架
    转载 Jquery中AJAX参数详细介绍
  • 原文地址:https://www.cnblogs.com/xiaocai0923/p/2255593.html
Copyright © 2011-2022 走看看