typedef - does not name a type

12,753

Solution 1

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

Solution 2

If you have mutual inclusion you need a forward declaration of your node type. Add this before the typedef: typedef struct node BTnode;

Share:
12,753
CDT
Author by

CDT

Updated on June 04, 2022

Comments

  • CDT
    CDT almost 2 years

    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?