Author: Bo Persson
Date: 03:02:13 11/09/02
Go up one level in this thread
On November 09, 2002 at 04:44:14, Sune Fischer wrote: >First Question: >I want to support some variants of chess, mostly fischer-random. >For this I need a member function pointer to point to a member function. >I must have the syntax wrong cause the compiler complains, this is what I do: > >class BOARD { >public: > void (*pGenCastleMoves)(); // is this correct declaration? Here is your problem: A pointer to member must be declared as a pointer to member of a specific class. You do this by using not just a *, but a classname::* construct. Try this line as void (BOARD::* pGenCastleMoves)(); > void GenNormalCastleMoves(); > void GenFischerCastleMoves(); >... >} > >I try and intialise it by: > >void GAME::SetNormal() { > variant=NORMAL; > Chessboard.pGenCastleMoves=Chessboard.GenNormalCastleMoves; >} > >Where GAME is a different class that controls settings for the entire game, like >the variant. It doesn't work though, I get: > >error C2440: '=' : cannot convert from 'void (__thiscall BOARD::*)(void)' to >'void (__cdecl *)(void)' > There is no context in which this conversion is possible > See, the compiler tries to hint at BOARD::* ! :-) The other two questions are beyond me... Bo Persson bop2@telia.com
This page took 0 seconds to execute
Last modified: Thu, 15 Apr 21 08:11:13 -0700
Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.