>>Why is element not declared?
Because you have recursive includes -- each header file includes the other.
In eventhandler.h try this:
#ifndef EVENTHANDLERH
#define EVENTHANDLERH
class element; // forward declaration of class
enum events {onClick, onHover};
typedef struct eventHandlerT {
void(*func)(element *elem);
events eventType;
} eventHandler;
#endif // EVENTHANDLERH
Ancient Dragon
Retired & Loving It
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
>>That's where the guards (the #ifdef stuff) are for right?
Nope. The guards prevent the same include file from being processed more than once. For example:
#include "element.h"
#include "element.h" // this one will be ignored
Your program had a different problem. The preprocessor attempted to process the line that used element *elm but class element had not been fully defined yet. With forward references the class doesn't have to be fully defined in order to declare a pointer to it.
Ancient Dragon
Retired & Loving It
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343