CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Dec 2004
    Posts
    4

    type def question

    the definition is circular I need to define edge in terms of node and node interms of edge?

    how do I do it please?
    Code:
    typedef struct
    	{
    	   int nWeight;
    	   node *Sibling;
    	}edge;
    	
    	typedef struct
    	{
    	   char Name[100];
    	   edge e[100];
    	} node;

  2. #2
    Join Date
    Nov 2004
    Location
    India
    Posts
    36

    Thumbs up Re: type def question

    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...
    Mukesh Vijay

  3. #3
    Join Date
    May 2000
    Location
    KY, USA
    Posts
    18,652

    Re: type def question

    Take a look at the following FAQ...

  4. #4
    Join Date
    Dec 2004
    Posts
    4

    Re: type def question

    thanks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured