Thread: nested structs

  1. #1
    Registered User
    Join Date
    Sep 2009

    nested structs

    do you guys know how to do operations with nested structs like

    struct x{
    struct y{........}
    say x is a linked list and y is also another type of linked list taht i want to exist inside x. However, the two linked lists are different in structures. The first linkedlist will store string and has a pointer to the next linkedlist and the second inner linked list will be inside the outer linkedlist keeping numbers of occurences of strings.

    Do you guys see any dangers in doing this?

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    struct a;
    struct b;
    struct a
        struct *b;
        ... stuff ...
    struct b
        struct *a;
        ... stuff ...
    You cannot make A contain B and B contain A, but you can make them contain pointers to the other type. Nesting structures is fine unless you try to make them contain eachother.

    Hope is the first step on the road to disappointment.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. nested structs
    By bandal27 in forum C Programming
    Replies: 26
    Last Post: 12-13-2008, 09:14 PM
  2. deriving classes
    By l2u in forum C++ Programming
    Replies: 12
    Last Post: 01-15-2007, 05:01 PM
  3. Nested structs
    By Sir Andus in forum C Programming
    Replies: 5
    Last Post: 11-28-2006, 10:31 AM
  4. Nested Structs
    By Monkey83 in forum C Programming
    Replies: 2
    Last Post: 09-15-2006, 11:03 AM
  5. accessing members in nested structs
    By amidstTheAshes in forum C Programming
    Replies: 2
    Last Post: 03-23-2005, 02:00 PM