Sign in to follow this  

c++ header include to class problem FIXED

This topic is 1961 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

/* FIXED */

Hello.
I am not sure how to describe problem, so il trow it at you right now.

At EventHandle.h, i included a "App.h" whyc contains "class App", and i tried to make a object of class App and i get this error
C:\c++ Project\WarCall 0.0.1\EventHandle.h|12|error: 'App' has not been declared| (Line with this error has alot of * simbols)
(i tryed including a "App.h" in .cpp file and making object of class App there, and it works)
ani hints how to bypass this.

[CODE]
/* EventHandle.h */
#ifndef EVENTHANDLE_H_INCLUDED
#define EVENTHANDLE_H_INCLUDED
#include <SDL.h>
#include "App.h"
class EventHandle
{
public:
SDL_Event eventList;
void EventMain(App *obj_App); ************************
void EventKeyDown();
void EventKeyUp();
};
#endif // EVENTHANDLE_H_INCLUDED



/* App.h */
#ifndef APP_H_INCLUDED
#define APP_H_INCLUDED
#include <SDL.h>
#include "define.h"
#include "EventHandle.h"
class App
{
/* Main stuff */
public:
int AppLoop(App *obj_App);
Uint8 Init();
void Exit();
Uint8 AppInit();
void AppExit();
private:
SDL_Surface *surf_Screen;
bool is_On;
public:
SDL_Surface** GETP_surf_Screen();
SDL_Surface* GET_surf_Screen();
void SET_surf_Screen(SDL_Surface*);
bool GET_is_On();
void SET_is_On(bool);
/* Class objects */
private:
EventHandle obj_EventHandle;
};
#endif // APP_H_INCLUDED
[/CODE]

/* FIXED */

Share this post


Link to post
Share on other sites
[quote name='fastcall22' timestamp='1343833694' post='4965219']
you'll learn that EventHandle.h doesn't need to include "App.h", but just needs a forward declaration of App.
[/quote]

Well if it was that simple.
I red it all, tryed what i learned, tryed alot of other stuff and im stuck again. Not the best fealing,


I get errors at :
/* EventHandle.h */ Error, forward declaration of struct App
/* EventHandle.cpp */ /* Error here, invalid use of incomplete type 'struct App' */

[CODE]
/* App.h */
#ifndef APP_H_INCLUDED
#define APP_H_INCLUDED
#include <SDL.h>
#include "EventHandle.h"
class App
{
/* Other stuff i have in this class */
/* Class objects */
private:
EventHandle obj_EventHandle;
};
#endif // APP_H_INCLUDED

/* EventHandle.h */
#ifndef EVENTHANDLE_H_INCLUDED
#define EVENTHANDLE_H_INCLUDED
#include <SDL.h>
class App ; /* 'Error, forward declaration of struct App' */
class EventHandle
{
public:
void EventMain(App *obj_App);
};
#endif // EVENTHANDLE_H_INCLUDED

/* EventHandle.cpp */
#include "EventHandle.h"
void EventHandle::EventMain(App *obj_App)
{
while(SDL_PollEvent(&eventList))
{
switch(eventList.type)
{
case SDL_QUIT:
obj_App->SET_is_On(false); /* Error here, invalid use of incomplete type 'struct App' */
break;
}
}
}
[/CODE]

Now i cant figure what em i suposed to do. Thats why i included "App.h".

Edit: Do take note, its not my entire code, i cliped out the part i dont think its needed. But i can post it if you require it.

Edit2:
Here is a zipped file of my Project "Warcall 0.0.1"
[url="http://www.mediafire.com/?cqw551i705qrc57"]http://www.mediafire...cqw551i705qrc57[/url]
Using codeblock and mingw32 compiler Edited by BaneTrapper

Share this post


Link to post
Share on other sites
Maybe you should try to include the App.h in the EventHandle.cpp (before or after including EventHandler.h)? Just a guess thought, but there's clearly no reference to App.h in the code you pasted above.

Share this post


Link to post
Share on other sites

This topic is 1961 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this