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

时间:2018-02-28 23:16:05

标签: c++ visual-c++ mfc

我在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在函数上方的私有头中声明。

1 个答案:

答案 0 :(得分:0)

确保您已包含“ColorGrid”的.h标题文件或添加了正确的参考。