class with no type error

I'm sure this is an easy one to answer but I just cant see what the problem is. I get the error:
pq.h:12: error: ISO C++ forbids declaration of ‘Node’ with no type
when I try to compile. That error occurs in this file:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#ifndef PQ_H
#define PQ_H

#include "voronoi.h"
#include "btree.h"

//main class for events
class Event {
	public:
		std::string type;
		Point coord;
		Node *arc1;
		Node *arc2;
		Node *arc3;
};

//create a PointEvent
Event PointEvent(Point mycoord);
Event CircleEvent(Node *arc1, Node *arc2, Node *arc3);

#endif 


But the Node class is in the header btree.h, which is included in the above file.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#ifndef BTREE_H
#define BTREE_H

#include "voronoi.h"
#include "pq.h"
#include <vector>

//Node class: leaves of binary tree
class Node {
	public:
		Node();
		Node(Point site);
		
	Point point;
	Node *left;
	Node *right;
	Event *cevent;
};
...


Here is the notable part of the btree.h file. If I comment out the Node declarations I get an error for the Event class, which is vise versa. I'm not sure what I'm missing so before I hulk out and smash things it would be good to get a fresh pair of eyes to see if im missing something. Thanks.
Last edited on
Neither the compiler nor we know what is Node, because you included headers circularly inside each other.
Last edited on
You have a circular dependency.

btree.h includes pq.h. pq.h includes btree.h but no code is included because of the header guard so Node has not yet been defined when Event is defined. The solution is to do forward declaration
class Node;
in pq.h instead of including btree.h. In pq.cpp you can include btree.h if you have to.
Last edited on
In header bree.h exclude statement

#include "pq.h"

and include statement

class Event;

Or create a third header that will contain

class Event;
class Head;
¿class Head? ¿why the namespace pollution?
Topic archived. No new replies allowed.