From: "Aaron & Rebecca" Newsgroups: comp.lang.c++,comp.os.msdos.djgpp,rec.games.programmer Subject: Re: pointer to function ?? Date: 2 Mar 1998 03:22:11 GMT Organization: AT&T WorldNet Services Lines: 54 Message-ID: <6dd8l3$gk2@bgtnsc02.worldnet.att.net> References: <6c7ltq$ms1$1 AT o DOT online DOT no> NNTP-Posting-Host: 12.68.104.50 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk x-no-archive:yes [iC] wrote in article <6c7ltq$ms1$1 AT o DOT online DOT no>... > ok, this might sound like a stupid question, but any way: > > I have a class witch looks somthing like this : > class Man { > int x,y,z; > --------- > void nextthink(); > } > > what I need is to be able to do somthing like : > nextthink() = run(); > > or > > nextthink() = attack(); > > later on in the game... > > any ideas ? class Action { virtual void doSomeThing( Man &M ) = 0; } class RunAction : public Action { virtual void doSomeThing( Man &M ); } class JumpAction : public Action { virtual void doSomeThing( Man &M ); } class ETC :public Action {... class Man { int x,y,z; --------- Action *NextThink; void nextthink() { this->NextTink.doSomeThing( this ); } } Hope that helps. Aaron Cosand.