Author: Michel Langeveld
Date: 09:41:36 10/29/03
Go up one level in this thread
>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
Hi Gerd,
Thanks for looking.
It's actually a static class function. I think the problem is that the compiler
doesn't know what object to use for calling this function. I made a complete
code that shows the same problem. Still puzzled.
#include <iostream>
#include <stdlib.h>
using namespace std;
#define MAXBUF_SIZE 1000
//typedef void (*line_event_type)(char *line);
typedef void (PGNtoScreen::*line_event_type)(char *line);
class PGNParse
{
public:
PGNParse()
{
}
void parse(char *strTextFile, line_event_type lineEvent)
{
char line[MAXBUF_SIZE];
FILE *f = fopen(strTextFile, "r");
while (!feof(f))
{
if (fgets(line, MAXBUF_SIZE, f) == NULL) continue;
lineEvent(line);
}
}
};
class PGNtoScreen
{
public:
PGNtoScreen()
{
lines = 0;
}
void PGNtoScreen::forEachLine(char *strLine)
{
cout << strLine;
lines++;
}
void PGNtoScreen::doit(char *strFileName)
{
PGNParse p;
p.parse(strFileName, forEachLine); //gives error C2664
cout << "Number of lines printed: " << lines << endl;
}
private:
int lines;
};
void main()
{
PGNtoScreen o;
o.doit("docc2003.pgn");
}
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.