From: Matthew Busigin Newsgroups: comp.lang.c++,comp.os.msdos.djgpp,rec.games.programmer Subject: Re: pointer to function ?? Date: 25 Feb 1998 00:43:52 GMT Organization: XWING Private Internet Site Lines: 52 Message-ID: References: <6c7ltq$ms1$1 AT o DOT online DOT no> NNTP-Posting-Host: 207.245.212.35 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk DeHackEd wrote: : ok, here are the ammendments : >I have a class witch looks somthing like this : : >class Man { : > int x,y,z; : > --------- : > void nextthink(); : void (*nextthink)(); : >} : > : >what I need is to be able to do somthing like : : >nextthink() = run(); : nextthink = run; : > : >or : > : >nextthink() = attack(); This is C, not C++, but I had to write a command parser for my 'talker system'. Here's what I did: int run_command( player *p, char *command_name, char *str ) { command *c; for ( c = c_start; c; c = c->next ) { if ( !strcasecmp( command_name, c->name ) ) { if ( c->priv_required > p->residency ) return 0; (c->function) ( p, str ); return 1; } } return 0; } c->function is declared as void *function. the (c->function) ( p, str ); is I think what you want. Am I correct, or should I stop drinking beer again? Matt -- ------------------------------------------------------------------------------ bLoOdRaGe, Coder of CiViL aNaRcHy. -=[telnet://Bird.ml.org 1998]=- ------------------------------------------------------------------------------ Politicians are the same over.