home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / lang / c / 19495 < prev    next >
Encoding:
Internet Message Format  |  1993-01-10  |  1.4 KB

  1. Path: sparky!uunet!spool.mu.edu!hri.com!enterpoop.mit.edu!eru.mt.luth.se!lunic!sunic!aun.uninett.no!nuug!ifi.uio.no!nntp.ifi.uio.no!jar
  2. From: jar@solva.ifi.uio.no (Jo Are Rosland)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: struct vs. typedef
  5. Message-ID: <JAR.93Jan10152829@solva.ifi.uio.no>
  6. Date: 10 Jan 93 14:28:29 GMT
  7. References: <uRL4wB7w165w@cybrspc.uucp>
  8. Sender: jar@ifi.uio.no (Jo Are Rosland)
  9. Organization: Dept. of Informatics, University of Oslo, Norway
  10. Lines: 31
  11. Nntp-Posting-Host: solva.ifi.uio.no
  12. In-Reply-To: roy%cybrspc@cs.umn.edu's message of Sat, 09 Jan 93 01:10:17 CST
  13. X-Md4-Signature: 31943765224661c43f5ea776587e1329
  14. Originator: jar@solva.ifi.uio.no
  15.  
  16. In article <uRL4wB7w165w@cybrspc.uucp> Roy M. Silvernail writes:
  17.  
  18.    typedef struct n {
  19.        int x,y;
  20.        struct n *last,*next, *up, *down;
  21.        void (*show)(struct n *);
  22.        int width;
  23.        void **value;
  24.    } ITEM;
  25.  
  26.    Now, this works, but it sure seems clumsy.  Is this really the only way
  27.    to do this type of construct?  If not, is it the optimal solution, or is
  28.    there some extremely clever trick I'm missing?
  29.  
  30. Given C, that's the best you can get.  You'll just have to get used to
  31. it, just like the rest of us :-).
  32.  
  33. C++ on the other hand, is another matter.  There the following code
  34. segment is legal:
  35.  
  36.     struct node {
  37.         node *prev;
  38.         node *next;
  39.         // whatever else you need
  40.     };
  41.  
  42.     node n1;
  43.     node *p1;
  44. --
  45. Jo Are Rosland
  46. jar@ifi.uio.no
  47.