two .h file is call each other, and causes compilation to fail
in stack_tree.h, i need to use TreeNode*,but it is defined in tree.h, so i try to include “tree.h”,just like the following code:
stack_tree.h:
#include "tree.h"
#define variable_type TreeNode*
#define MaxSize 50
typedef struct stack
{
variable_type data[MaxSize];
int top;
}SqStack; //栈的顺序存储
but in tree.h , i need to use SqStack, so i have to include “stack_tree.h”,This causes the two h files to include each other,then compile is false
tree.h:
typedef struct tree
{
int val;
struct tree *lnext;
struct tree *rnext;
SqStack* next;
}TreeNode;
how can i solve this problem?
New contributor
cooffeeboy is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.