Message-ID: <393CAD2A.7DD65072@gmx.de> From: Ole Reinartz Organization: Nokia X-Mailer: Mozilla 4.06 [en] (WinNT; I) MIME-Version: 1.0 Newsgroups: comp.os.msdos.djgpp Subject: Re: template error References: <39190F26 DOT 609A37C8 AT home DOT com> <391C05F1 DOT 1AF32F2D AT gmx DOT de> <391C2047 DOT 57740096 AT home DOT com> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Lines: 46 Date: Tue, 06 Jun 2000 07:45:21 GMT NNTP-Posting-Host: 172.25.108.216 X-Complaints-To: newsmaster AT nokia DOT com X-Trace: news1.nokia.com 960277521 172.25.108.216 (Tue, 06 Jun 2000 10:45:21 EET DST) NNTP-Posting-Date: Tue, 06 Jun 2000 10:45:21 EET DST To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com Robin Johnson wrote: > I am currently writing a templated tree system that I need, > and it needs to be able to do traversal via a callback mechinism. > > template > void traverse_pre(tNode *tree,tCallBack Visit) > { if(!tree) return; > Visit(tree); > traverse_pre(tree->left); > traverse_pre(tree->right); > } > > Ole Reinartz wrote: > > > > Robin Johnson wrote: > > > > > I am getting an error that I am at a complete loss to explain... > > > The g++ FAQ mentions nothing like it, so I thought I'd ask just to be sure... > > > > > > Error: template declaration of `typedef void ( tCallBack)(struct tNode > > > *&)' > > > > > > Code Segment: > > > template > > > struct tNode { > > > tItem data; > > > tNode *right, *left; > > > }; > > > > > > template > > > typedef void tCallBack(tNode* &node); //error here Robin, Now I see better (I hope). Now what should tCallBack be? A function pointer to a function which takes a tNode object and returns nothing?. Hm... So you need a pointer to a template function. No easy... Have a look at this: http://www.bestweb.net/~rhickey/functor.html It is something about 'template functors' which sounds very near to what you need. Hope this helps, Ole