vc ++未声明的标识符,虽然它已声明

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了vc ++未声明的标识符,虽然它已声明相关的知识,希望对你有一定的参考价值。

我在tetrisdoc.h头文件中获取了'm_colorGrid'的未声明标识符,尽管它声明了:

请参阅下面的代码段:

// TetrisDoc.h : interface of the CTetrisDoc class
//


#pragma once
#include "Figure.h"

typedef CList<int> IntList; 
const int FIGURE_ARRAY_SIZE = 7; 
class CTetrisDoc : public CDocument
{
protected: // create from serialization only
    CTetrisDoc();
    DECLARE_DYNCREATE(CTetrisDoc)
public:
    virtual ~CTetrisDoc();


private:
    ColorGrid m_colorGrid;
    Figure m_activeFigure, m_nextFigure;
    int m_iScore;
    IntList m_scoreList;
    const CRect NEXT_AREA, SCORE_AREA;
    static Figure m_figureArray[FIGURE_ARRAY_SIZE];

// Operations
public:
    void SaveScoreList();
    virtual void Serialize(CArchive& archive);
    int GetScore() const { return m_iScore; }
    const IntList* GetScoreList() { return &m_scoreList; }
    const ColorGrid* GetGrid() 
    { 
        ColorGrid* pm_colorGrid = &m_colorGrid;
        return pm_colorGrid;
    }
    const Figure& GetActiveFigure() { return m_activeFigure; }
    const Figure& GetNextFigure() { return m_nextFigure; }
    void LeftArrowKey(); 
    void RightArroyKey(); 
    void UpArrowKey(); 
    void DownArrowKey();
    BOOL Timer(); 
    void SpaceKey(); 
    enum COLOR {RED=0,BROWN=1,TURQUOISE=2,GREEN=3,BLUE=4,PURPLE=5,YELLOW=6};
    enum ORIENTATION { NORTH = 0, SOUTH = 1,  EAST = 2, WEST = 3 };


// Overrides
public:
    virtual BOOL OnNewDocument();
#ifdef SHARED_HANDLERS
    virtual void InitializeSearchContent();
    virtual void OnDrawThumbnail(CDC& dc, LPRECT lprcBounds);
#endif // SHARED_HANDLERS

#ifdef _DEBUG
    virtual void AssertValid() const;
    virtual void Dump(CDumpContext& dc) const;
#endif

protected:

// Generated message map functions
protected:
    DECLARE_MESSAGE_MAP();

private:
    void GameOver(); 
    BOOL NewGame(); 
    int AddScoreToList(); 
    void DeleteFullRows(); 
    BOOL IsRowFull(int iRow);
    void FlashRow(int iFlashRow);
    void DeleteRow(int iDeleteRow);

#ifdef SHARED_HANDLERS
    // Helper function that sets search content for a Search Handler
    void SetSearchContent(const CString& value);
#endif // SHARED_HANDLERS
};

这是实际的错误日志:

错误8错误C2065:'m_colorGrid':未声明的标识符c: users ary documents visual studio 2013 projects tetris tetris tetrisdoc.h 36 1俄罗斯方块

这是截图:enter image description here

如您所见,m_colorGrid在函数上方的私有头中声明。

答案

确保您已包含“ColorGrid”的.h头文件或添加了正确的引用。

以上是关于vc ++未声明的标识符,虽然它已声明的主要内容,如果未能解决你的问题,请参考以下文章

引用的 DLL 未声明?

托管代码中未声明的标识符错误...Visual C#

VC++2010 Cout 未声明的标示符

vb dll和工程如果想要共用相同的变量应该如何声明

声明提前js变量

C++ 类实例标识符未声明