From: "Les Matheson" Newsgroups: comp.lang.c++,comp.os.msdos.djgpp,rec.games.programmer Subject: Re: pointer to function ?? Date: Sun, 15 Feb 1998 13:42:00 -0000 Organization: MindSpring Enterprises Lines: 60 Message-ID: <6c7nev$9ac@camel19.mindspring.com> References: <6c7ltq$ms1$1 AT o DOT online DOT no> NNTP-Posting-Host: ip169.santa-ana7.ca.pub-ip.psi.net To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk There are a number of ways to do what you want, but the most obvious is to use function pointers: class Man { public: void (Man::*nextAction)(); // pointer to next action func void Jump(); void Run(); void Spit(); }; void test() { Man m; m.nextAction = &Man::Jump; (m.*m.nextAction)(); m.nextAction = &Man::Run; (m.*m.nextAction)(); } Les *** Reply email address: remove 'nospam-'... (Don't you just hate that stuff?) [iC] wrote in message <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 ? > > > > > > > > > > >