博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
error C2065: 'theApp' : undeclared identifier
阅读量:6936 次
发布时间:2019-06-27

本文共 1364 字,大约阅读时间需要 4 分钟。

解决办法一:

在你要访问的地方的 .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_)

 

 

 

转载于:https://www.cnblogs.com/xiaocai0923/archive/2011/11/19/2255593.html

你可能感兴趣的文章