Incomplete type not allowed error

I am wondering why I am seeing this error - "Incomplete type not allowed"
1
2
3
4
5
6
#include <iostream>
using namespace std;
class Node {
	Node prev, next;// Error seen in this line
	int key;
};


The error disappears when I change it to Node *prev,*next;
Any explanation on why the pointer to node works but not the objects of node class?
If you were to have each node object contain 2 more node objects, every node object would contain an infinite amount of node objects. In other words it's impossible and that's why you are getting an error. Having a pointer too another node object on the other hand is perfectly fine.
Thanks that makes sense. I did not think of that :)
Topic archived. No new replies allowed.