#ifndef OBJECT_H
#define OBJECT_H
#include "SDL.h"
#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
#include <vector>
#include <stdlib.h> // Include this to use system()
#include <iostream> // Include our standard header
#include <string> // Include this to use strings
#include <fstream>
#include <libiberty.h>
#include "Sprite_Handler.h"//but im including the type here and i know its spelled right
class Object
{
public:
int z;
Object(int x , int y , const char* New_I , Sprite_Handler* Sprite_Handler1); //in this line
SDL_Rect R_Object;
SDL_Surface* I_Object;
};
Object::Object(int x,int y,const char* New_I, Sprite_Handler* Sprite_Handler1)
{
R_Object.x = x;
R_Object.y = y;
I_Object = SDL_LoadBMP(New_I);
Sprite_Handler1->addsprite(this);
};
#endif
compiler insaine?
im staring to think my compiler should start to seee a doctor any way heres the problem
my compiler gives me this error
19 C:\Dev-Cpp\projects\Homeland\Object.h type specifier omitted for parameter `Sprite_Handler'
i dunno maybe i should see someone but it looks ok to me
thanks[smile]
[Edited by - raptorstrike on November 27, 2004 8:17:02 PM]
Shouldn't you be using -> in Sprite_Handler1.addsprite(this); since Object::Object(....Sprite_Handler* Sprite_Handler1)
here it is
#ifndef SPRITE_HANDLER_H#define SPRITE_HANDLER_H#include "SDL.h"#include <stdio.h>#include <stdlib.h>#include <windows.h>#include <vector>#include <stdlib.h> // Include this to use system()#include <iostream> // Include our standard header#include <string> // Include this to use strings#include <fstream>#include <libiberty.h>#include "Object.h"using namespace std;class Sprite_Handler{ public: Sprite_Handler() {}; void TempRectBlit(SDL_Surface* src,SDL_Surface* dst,SDL_Rect Parent_Rect); void DrawSprites(SDL_Surface* dst); vector<Object*> Sprites; void addsprite(Object* n_object); };#endif
Quote:Original post by raptorstrikeFrom your error I can tell that in your source file you are including Sprite_Handler.h. This file includes object.h the be able to refrence the Object class. But the object.h can't include the Sprite_Handler.h because that would include Object.h again! That is why you can't access Sprite_Handler in Object.h!
here it is
Since you are using pointers you can solve this problem by using forward declarations instead of
#include "object.h"
&
#include "sprite_handler.h"
in sprite_handler.h and object.h respectively. In object.h this would force you to move the implementation of your Object constructor to a cpp file.
here is your new object.h:
#ifndef OBJECT_H#define OBJECT_H#include "SDL.h"#include <stdio.h>#include <stdlib.h>#include <windows.h>#include <vector>#include <stdlib.h> // Include this to use system()#include <iostream> // Include our standard header#include <string> // Include this to use strings#include <fstream>#include <libiberty.h>//#include "Sprite_Handler.h"//but im including the type here and i know its spelled rightclass Sprite_Handler;class Object{ public: int z; Object(int x , int y , const char* New_I , Sprite_Handler* Sprite_Handler1); //in this line SDL_Rect R_Object; SDL_Surface* I_Object;}; #endif
this is your new Sprite_Handler.h:
#ifndef SPRITE_HANDLER_H#define SPRITE_HANDLER_H#include "SDL.h"#include <stdio.h>#include <stdlib.h>#include <windows.h>#include <vector>#include <stdlib.h> // Include this to use system()#include <iostream> // Include our standard header#include <string> // Include this to use strings#include <fstream>#include <libiberty.h>// not #include "Object.h"class Object;using namespace std;class Sprite_Handler{ public: Sprite_Handler() {}; void TempRectBlit(SDL_Surface* src,SDL_Surface* dst,SDL_Rect Parent_Rect); void DrawSprites(SDL_Surface* dst); vector<Object*> Sprites; void addsprite(Object* n_object); };#endif
well i tried what you said but got a bunch of INVALID use of struct in my cpp files so using your same basic logic i moved the constructer to a diffrent source file and now it works
Quote:Original post by raptorstrikeI dont really know what you mean... I said you should move the constructor to a cpp file. The cpp file must include object.h?
well i tried what you said but got a bunch of INVALID use of struct in my cpp files so using your same basic logic i moved the constructer to a diffrent source file and now it works
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement