#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Posts
    13
    Rep Power
    0

    Is it possible to use struct's own name in its body?


    Code:
    struct s
    {
       struct s ss;
       int func(struct s);
    };
    Is any of the above possible? How? Thanks.
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Feb 2004
    Location
    San Francisco Bay
    Posts
    1,939
    Rep Power
    1313
    This is not possible in C or C++. However, a struct can contain pointers to structs of the same type:
    Code:
    struct a {
        struct a *p;
        struct a *q;
    };

IMN logo majestic logo threadwatch logo seochat tools logo