Path: chuka.playstation.co.uk!news From: daniel@reichardt.ch (Daniel Hartmeier) Newsgroups: scea.yaroze.freetalk Subject: Re: Net Yaroze C++ Examples Date: Fri, 28 May 1999 19:38:16 GMT Organization: Reichardt Informatik AG Lines: 31 Message-ID: <374fef72.13823667@news.playstation.co.uk> References: <374c6512.1232873@news.scea.sony.com> <374E06E4.5D701DDC@identicalsoftware.com> <37505449.1115333@news.playstation.co.uk> <7imgt2$3vd2@scea> NNTP-Posting-Host: dial-in-65.magnet.ch Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Newsreader: Forte Agent 1.5/32.451 On Fri, 28 May 1999 09:44:32 -0700, "Steve Spiller" wrote: > Just do it the old fashioned way! > > typedef enum { > ntTile, > ntEnemy, > ntLevel > } NODETYPE; > > typedef struct _tagNode { > NODETYPE nNodeType; > void *pItem; > struct _tagNode *pNext; > } NODE, *LPNODE; > > Then you just create structures for holding all your different node types > and when you walk down the list you cast the void pointer to whatever type > the nNodeType indicates. Voila! Generic linked list in C. :) Yeah, and my code is full of ugly casts and I loose even the weak type-safety that there was before. And if I add a new NODETYPE, I have to check through my whole code. This is evil. :-) Regards, -- Daniel Hartmeier PGP 6A3A7409 ICQ# 12742482 "The woods are lovely, dark and deep. But I have promises to keep, And lines to code before I sleep, And lines to code before I sleep."