Reputation: 10621
i have two headers
in header “BinTree.h":
typedef struct node {
ElemType data;
struct node *lchild;
struct node *rchild;
}BTNode;
in header "Queue.h"(which includes BinTree.h):
typedef BTNode* Dataype;
at compiling the compilor said: error: ‘BTNode’ does not name a type
What's wrong?
Upvotes: 2
Views: 15435
Reputation: 18348
If you have mutual inclusion you need a forward declaration of your node type. Add this before the typedef
: typedef struct node BTnode;
Upvotes: 1
Reputation: 59997
Did you include BinTree.h
in Queue.h
before the declaration?
Or have you .cpp
(or moral equivalent) include it beforehand
EDIT FOR CDT
Forward declarations are the answer.
As you did not post the code it is difficult to tell.
But I would hazzard a guess here
typedef struct node BTNode;
whould hit the ticket in Queue.h
Upvotes: 2