Function pointer to a non-static method
שלום,
ברצוני להגדיר משתנה מסוג מצביע לפונקציה שמקבל ערך של מתודה של קלאס.
אני מפתח ב- V.S 2010 וונראה שניתן להגדיר לבצע השמה רק של מתודה סטטית.
מה הסיבה לכך ?
תודה,
צהלול
#include "stdafx.h"
#include <stdio.h>
void my_int_func(int x)
{
printf( "%d\n", x );
}
class CTiming
{
public:
static void WriteFifo (int x);
};
void CTiming::WriteFifo (int x)
{
printf ("x=%d\n",x);
}
int _tmain(int argc, _TCHAR* argv[])
{
CTiming *pTiming = new CTiming;
void (*foo)(int);
foo = pTiming->WriteFifo;
foo (5);
return 0;
}
שלום,
ברצוני להגדיר משתנה מסוג מצביע לפונקציה שמקבל ערך של מתודה של קלאס.
אני מפתח ב- V.S 2010 וונראה שניתן להגדיר לבצע השמה רק של מתודה סטטית.
מה הסיבה לכך ?
תודה,
צהלול
#include "stdafx.h"
#include <stdio.h>
void my_int_func(int x)
{
printf( "%d\n", x );
}
class CTiming
{
public:
static void WriteFifo (int x);
};
void CTiming::WriteFifo (int x)
{
printf ("x=%d\n",x);
}
int _tmain(int argc, _TCHAR* argv[])
{
CTiming *pTiming = new CTiming;
void (*foo)(int);
foo = pTiming->WriteFifo;
foo (5);
return 0;
}