When starting to learn the binary tree, I find that I am not clear with the struct.So here comes this note.
First, when it comes to Struct, it may like this.
struct Table{
int legs;
char name;
};
However, mostly we use it like this.
typedef struct Table{
int legs;
struct Table *next;
char name;
}Table,*TableList;
so, what does typedef, Table,*TableList mean?
if you use typedef in the code above, it means the Table[structure tag] could be used to create Struct type variable like Table t; t.legs=4; the Table behalf of the structure.
if there is no typedef, you have to write struct Table t each time you create a structure type variable.
The difference is to write struct or not, that typedef brings.
if we omit the structure tag,
typedef struct {
int legs;
struct Table *next;
char name;
}Table,*TableList;
the Table is the only one structure entity we could use.
The *TableList is a structure pointer, a pointer point to the struct node.
Things get different in C++
typedef struct Table{
int legs;
}Table1;
The Table1 is a structure entity , use
Table1 t;
t.legs=4;
struct Table{
int legs;
}Table2;
TheTable2 is a structure variable, use
Table2.legs=4;
updating ........