Author: Gerd Isenberg
Date: 07:36:22 10/29/03
Go up one level in this thread
On October 29, 2003 at 09:50:23, Michel Langeveld wrote:
>I have a problem with casting function pointers between two classes.
>
>The error is as follows:
>error C2664: 'PGNParse::parse' cannot convert parameter 2 from
>void(char *) to 'on_game_function_type'
>
>Is there anybody who has experience in solving this kind of error? Last time I
>changed a lot of code to jump over this error, but I'm curious if there is a
>nice approach to fix it.
>
>----------- some code out of PGNtoScreen -------------------
>
>void PGNtoScreen::forEachGame(char *moves)
>{
> cout << moves << endl;
>}
>
>void PGNtoScreen::doit(char *strFileName)
>{
> PGNParse p;
>
> p.parse(strFileName, forEachGame); //gives error C2664
>}
>
>----------- some code out of PGNParse -------------------
>
>typedef void (*on_game_function_type)(char *moves);
>
>void PGNParse::parse(char *strTextFile, on_game_function_type on_game)
>{
> char *all_moves;
> ....
> on_game( all_moves );
> ....
>}
Hi Michel,
I guess forEachGame is a static class function.
Then you have to use explicite class specifiers in your typedef:
typedef void (PGNtoScreen::*on_game_function_type)(char *moves);
Gerd
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.