From: "Didier Trosset-Moreau" Newsgroups: comp.lang.c++,comp.os.msdos.djgpp,rec.games.programmer References: <6c7ltq$ms1$1 AT o DOT online DOT no> <6dd8l3$gk2 AT bgtnsc02 DOT worldnet DOT att DOT net> Subject: Re: pointer to function ?? Date: Tue, 3 Mar 1998 09:58:03 +0100 Lines: 41 NNTP-Posting-Host: ts1gexp108.iprolink.com Message-ID: <34fbc5e5.0@news.iprolink.ch> Organization: Internet Prolink SA Customer To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk > 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(); > } Here, let's say nextthink is a pointer to a function class Man { //... void (*nextthink)(); }; > what I need is to be able to do somthing like : > nextthink() = run(); > > or > > nextthink() = attack(); You have to declare (and further define) class Man { //... void run(); void attack(); }; Then you can write : nextthink = run; nextthink = attack; > later on in the game... > > any ideas ?