Click to See Complete Forum and Search --> : type def question


Denion
December 8th, 2004, 11:45 PM
the definition is circular I need to define edge in terms of node and node interms of edge?

how do I do it please?

typedef struct
{
int nWeight;
node *Sibling;
}edge;

typedef struct
{
char Name[100];
edge e[100];
} node;

mukeshvijay79@hotmail.com
December 9th, 2004, 12:09 AM
It won't compile bcoz node is used before definition. So, forward declaration comes to save u. Use this

struct node;
typedef struct
{
int nWeight;
node* Sibling;
}edge;

typedef struct node
{
char Name[100];
edge e[100];
}NODE ;

Now struct node has been declared before use and later defined. It works....
Be alive...

Andreas Masur
December 9th, 2004, 03:01 AM
Take a look at the following FAQ (http://www.codeguru.com/forum/showthread.php?t=312455)...

Denion
December 9th, 2004, 05:17 AM
thanks