Syntax error: identifier not found... But i have included it? C++ -


i have game class -

game.h:

#pragma once  #include "d3dgraphics.h" #include "mouse.h" #include "screen.h" #include "script.h"  class game { public:     game( hwnd hwnd, const mouseserver &mouseserver, const screenserver &screenserver );     void go();     void config();  private:         void composeframe();      d3dgraphics gfx;     mouseclient mouse;     screenclient screen;      script * scripts[ 1 ]; }; 

i have d3dgraphics class -

d3dgraphics.h:

#pragma once  #include <d3d9.h> #include <d3dx9.h>  #include "screen.h" #include "script.h"  #define customfvf (d3dfvf_xyzrhw | d3dfvf_diffuse)  struct customvertex {     float x, y, z, rhw;    // d3dfvf_xyzrhw flag     dword color;    // d3dfvf_diffuse flag };  class d3dgraphics { public:     d3dgraphics( hwnd hwnd, screenclient screenclient );     ~d3dgraphics();      void begin();     void end();     void present();      void createviewport();     void definetext( script *script );      lpdirect3d9 d3dobject;     lpdirect3ddevice9 d3ddevice;     d3dpresent_parameters presparams;     hresult hr;      float resizelockratio( float width, float height, float scalingwidth );     float getgameoffset( float resizedimageheight );      void drawrectangle( int x, int y, int width, int height, d3dcolor backgroundcolor );     void drawactionbar();     void rendertext( script *script ); private:     lpdirect3dvertexbuffer9 vbuffer;     screenclient screen; }; 

notice game class has both

d3dgraphics gfx; script * scripts[ 1 ]; 

in game.cpp make version of d3dgraphics , place in gfx:

game.cpp:

#include "game.h"  game::game( hwnd hwnd, const mouseserver &mouseserver, const screenserver &screenserver )     :   mouse( mouseserver ),         screen( screenserver ),         gfx( hwnd, screen ) {     //gfx.d3ddevice->setrenderstate( d3drs_alphablendenable, true);      std::string debugstringresult;     std::stringstream debugstring;     debugstring << "mouse x: " << mouse.getmousex() << ",\nmouse y: " << mouse.getmousey() << ",\nleft mouse down: " << mouse.leftmousedown() << ",\nright mouse down: " << mouse.rightmousedown() << ",\nscreen width: " << screen.getscreenwidth() << ",\nscreen height: " << screen.getscreenheight() << "\nsystem resolution: " << screen.getwindowwidth() << " x " << screen.getwindowheight();     debugstringresult = debugstring.str();         scripts[ 0 ] = new script( gfx, "arial", 0, 0, 255, 0, debugstringresult, 10, 10, ( screen.getwindowwidth() - 10 ), ( screen.getwindowheight() - 10 ) ); } 

i have script class -

script.h:

#pragma once  #include "d3dgraphics.h" #include <sstream>  class script { public:      script( d3dgraphics gfx,             lpcstr font,              int alpha, int r, int g, int b,              std::string text,              float x, float y, float width, float height );      lpcstr font;     int alpha, r, g, b;     std::string text;     float x, y, width, height;     d3dcolor color;     rect rect;     id3dxfont *handle; private: }; 

my script constructor looks this:

script.cpp:

#include "script.h"  script::script( d3dgraphics gfx,                 lpcstr font,                  int alpha, int r, int g, int b,                  std::string text,                  float x, float y, float width, float height ) {     gfx.definetext( ); } 

and on. error when compile application comes as:

error   1   error c2061: syntax error : identifier 'd3dgraphics'    c:\users\james\documents\visual studio 2012\projects\thegame\thegame\script.h   9   1   thegame error   8   error c2061: syntax error : identifier 'd3dgraphics'    c:\users\james\documents\visual studio 2012\projects\thegame\thegame\script.h   9   1   thegame error   9   error c2661: 'script::script' : no overloaded function takes 11 arguments   c:\users\james\documents\visual studio 2012\projects\thegame\thegame\game.cpp   14  1   thegame error   10  error c2061: syntax error : identifier 'script' c:\users\james\documents\visual studio 2012\projects\thegame\thegame\d3dgraphics.h  28  1   thegame error   11  error c2061: syntax error : identifier 'script' c:\users\james\documents\visual studio 2012\projects\thegame\thegame\d3dgraphics.h  40  1   thegame error   12  error c2660: 'd3dgraphics::definetext' : function not take 1 arguments c:\users\james\documents\visual studio 2012\projects\thegame\thegame\script.cpp 9   1   thegame error   13  error c2061: syntax error : identifier 'd3dgraphics'    c:\users\james\documents\visual studio 2012\projects\thegame\thegame\script.h   9   1   thegame error   16  error c2061: syntax error : identifier 'd3dgraphics'    c:\users\james\documents\visual studio 2012\projects\thegame\thegame\script.h   9   1   thegame 

line 9 of script.h is:

script( d3dgraphics gfx,... 

i have no idea on earth happening? have clue, i've been poking @ code dead animal past 2 hours.

you have circular dependency, might need specify want d3dgraphics compiled before script, done by:

#pragma once  #include "d3dgraphics.h" #include <sstream>  class d3dgraphics;  class script { public:      script( d3dgraphics gfx,             lpcstr font,              int alpha, int r, int g, int b,              std::string text,              float x, float y, float width, float height );      lpcstr font;     int alpha, r, g, b;     std::string text;     float x, y, width, height;     d3dcolor color;     rect rect;     id3dxfont *handle; private: }; 

Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -