Path: chuka.playstation.co.uk!news From: sosman@terratron.com (Steven Osman) Newsgroups: scea.yaroze.freetalk Subject: Re: Net Yaroze C++ Examples Date: Sat, 29 May 1999 14:17:36 GMT Organization: PlayStation Net Yaroze (SCEE) Lines: 46 Message-ID: <3753f673.757496562@news.playstation.co.uk> References: <374c6512.1232873@news.scea.sony.com> <374E06E4.5D701DDC@identicalsoftware.com> <37505449.1115333@news.playstation.co.uk> <7imgt2$3vd2@scea> <3750aa84.6218571@news.playstation.co.uk> NNTP-Posting-Host: 209.27.57.69 Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Newsreader: Forte Agent 1.5/32.452 On Sat, 29 May 1999 09:08:40 GMT, daniel@reichardt.ch (Daniel Hartmeier) wrote: >On Fri, 28 May 1999 09:44:32 -0700, "Steve Spiller" > wrote: (snip) >> typedef struct _tagNode { >> NODETYPE nNodeType; >> void *pItem; >> struct _tagNode *pNext; >> } NODE, *LPNODE; (snip) >Your example will create less code than > > template > struct Node > { > T *item; > Node *next; > }; > >as the C++ compiler will produce separate code for each type T used. > >But use of the template establishes the rule that a list of type Node >will only contain items of the same type T (or do you want to have mixed >lists?), and removes the need for run-time checks of the node type, >making the application smaller, faster and safer. Well, yes and no. Same type T, but lets not forget that this is C++ we are talking about. T can be a superclass of every character in the game, or every object in the game, or everything. Just put a method called animate or draw in T, and all of the sudden, you don't NEED the runtime checks, even though you've somewhat diversified the contents of your list. What's more, they can move, think, or do whatever! Now your argument becomes more appealing. Steven