Jump to content
  • Advertisement
Sign in to follow this  
raptorstrike

compiler insaine?

This topic is 4955 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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'

#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



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]

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
Shouldn't you be using -> in Sprite_Handler1.addsprite(this); since Object::Object(....Sprite_Handler* Sprite_Handler1)

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
Quote:
Original post by raptorstrike
here it is
From 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!

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 right

class 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



Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
Quote:
Original post by raptorstrike
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
I dont really know what you mean... I said you should move the constructor to a cpp file. The cpp file must include object.h?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!