I try to reference a struct from another class in my code and it gives me an error, saying I have a syntax problem.
#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] ); }; That's the struct in Figure.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 ); }; And that is where I reference it, from another header file called UI.h. I know there is a problem with referencing structures, I just don't know how to fix it. Simple problem, any one wanna help?
The problem is not that Figure Type is declared outside of Figure.h, or that it is private as opposed to public.
Error Reports
Error 1 error C2653: 'Figure' : is not a class or namespace name c:\users\jim\documents\c++\roguelike\roguelike\ui.h 13 1 roguelike
Error 3 error C2653: 'Figure' : is not a class or namespace name c:\users\jim\documents\c++\roguelike\roguelike\ui.h 14 1 roguelike
Error 2 error C2061: syntax error : identifier 'FIGURE_TYPE' c:\users\jim\documents\c++\roguelike\roguelike\ui.h 13 1 roguelike
Error 4 error C2061: syntax error : identifier 'FIGURE_TYPE' c:\users\jim\documents\c++\roguelike\roguelike\ui.h 14 1 roguelike
Figure::is doing? Do you thinkFigureis a namespace? A type? Or something else? (It's hard to correct your misunderstanding when I don't know what your reasoning is.)Figureis a class type. You're wrong. The OP's syntax and understanding is 100% correct.