Path: utzoo!attcan!uunet!husc6!rutgers!columbia!garfield.columbia.edu!eppstein From: eppstein@garfield.columbia.edu (David Eppstein) Newsgroups: comp.lang.c++ Subject: "recursive" function prototype? Message-ID: <5632@columbia.edu> Date: 11 May 88 21:08:28 GMT References: <2549@phoenix.Princeton.EDU> <461@goofy.megatest.UUCP> <7104@bellcore.bellcore.com> <11374@mimsy.UUCP> Sender: nobody@columbia.edu Organization: Columbia University CS Department Lines: 20 sjs@spectral.ctt.bellcore.com (Stan Switzer): > The lack of functions returning {functions returning}* can hardly be > considered a serious flaw in C, but such functions ARE useful. chris@mimsy.UUCP (Chris Torek): > Agreed. Traditionally, this has been done with ... [icky casts -- DE]. A cleaner approach is to wrap the function pointers in a recursive struct: struct foo; typedef foo (* foo_func)(); struct foo { foo_func fn_ptr; foo(foo_func f) { fn_ptr = f; } foo operator()() { return (*fn_ptr)(); } }; foo bar() { return bar; } -- David Eppstein eppstein@garfield.columbia.edu Columbia U. Computer Science