错误C2061在visual studio中

Jam*_*ley 3 c++

我尝试在我的代码中引用另一个类的结构,它给了我一个错误,说我有语法问题.

#pragma once

#include "Definitions.h"

#include "GV.h"
#include "UI.h"
#include "Tile.h"
#include "Item.h"

class Figure {
public:
    //Figure index
    struct FIGURE_TYPE {
        //Where to crop the image from
        SDL_Rect crop;
        int x;
        int y;
    };

    //The game figure
    FIGURE_TYPE figure_index[FIGURE_COUNT];

    //The figure array
    int figure_array[MAP_HEIGHT / 64][MAP_WIDTH / 64];

    //Functions
    Figure ( void );
    bool draw_figures ( SDL_Surface* screen, SDL_Surface* figures, SDL_Rect camera, Figure::FIGURE_TYPE figure_spec[FIGURE_COUNT] );
};
Run Code Online (Sandbox Code Playgroud)

那是图.h中的结构,

#pragma once

#include "Definitions.h"

#include "GV.h"
#include "Tile.h"
#include "Item.h"
#include "Figure.h"

class UI {
public:
    UI ( void );
    void set_camera ( SDL_Rect& camera, Figure::FIGURE_TYPE figure_spec[FIGURE_COUNT] );
    bool draw_map ( SDL_Surface* screen, SDL_Rect& camera, SDL_Surface* tiles, SDL_Surface* figures, Figure::FIGURE_TYPE figure_spec[FIGURE_COUNT] );
    bool draw_status ( void );
};
Run Code Online (Sandbox Code Playgroud)

这就是我从另一个名为UI.h的头文件中引用它的地方.我知道引用结构存在问题,我只是不知道如何修复它.简单的问题,任何人都想帮忙吗?

问题不是图类型在图.h之外声明,或者它是私有的而不是公共的.

错误报告

错误1错误C2653:'图':不是类或命名空间名称c:\ users\jim\documents\c ++\roguelike\roguelike\ui.h 13 1 roguelike

错误3错误C2653:'图':不是类或命名空间名称c:\ users\jim\documents\c ++\roguelike\roguelike\ui.h 14 1 roguelike

错误2错误C2061:语法错误:标识符'FIGURE_TYPE'c:\ users\jim\documents\c ++\roguelike\roguelike\ui.h 13 1 roguelike

错误4错误C2061:语法错误:标识符'FIGURE_TYPE'c:\ users\jim\documents\c ++\roguelike\roguelike\ui.h 14 1 roguelike

Ada*_*eld 10

你有一个循环依赖:UI.h依赖于Figure.h,而Figure.h依赖于UI.h. 您需要通过删除#include另一个文件中的一个文件来打破循环依赖关系.在这种情况下,由于我没有在图.h中看到任何在UI.h中使用任何内容的东西,所以你应该#include "UI.h"从图.h中删除并完全设置.