i wrote a simple struct
it says i got syntax error
i cant se my error here
??
Code:typedef struct node{ node *left; node *right; int data; }node;
i wrote a simple struct
it says i got syntax error
i cant se my error here
??
Code:typedef struct node{ node *left; node *right; int data; }node;
do you want the same name for the struct tag and its alias?
We've done this before. The name "node" does not exist until you get to the actual typedef at the bottom line. Until then you must use the actual name of the type, "struct node".
Yes, because node was not declared until after the struct was defined. Here are two solutions:
Code:typedef struct node { struct node *left; struct node *right; int data; } node;Code:typedef struct node node; struct node { node *left; node *right; int data; };
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
this is a combination of struct and typedef
instead writing struct node each time.
using this code i can write only "node"
which i wrote in the end.
That's maybe two direction link list
This is my first post!
I‘'m from China and my English is bad……
Do you understand what I say??
Last edited by liyanhong; 11-18-2008 at 09:15 AM.
Compilers can produce warnings - make the compiler programmers happy: Use them!
Please don't PM me for help - and no, I don't do help over instant messengers.
its HE