Let's say I implement a tree in following way:
struct Node;
typedef struct Node Tree
struct Node {
int value;
Tree *left;
Tree *right;
};
Now i wanted to experiment with pointers to struct:
const Tree * a;
This works completely fine, I couldnt assign the value pointed by a to anything else, etc. However, I wanted to make things easier and changed typedef to following:
typedef struct Node * Tree
And now, even though it seems obvious that
const Tree a;
should behave the same way the previous declaration did, it doesnt, instead it behaves like a const pointer, meaning i cant write
a = ..stmh_else..
Why is that happening? Is it some nuance with typedef that I dont know?