[問題] 指向 class function 的函式指標
各位好,
最近遇到一個關於指向一個 class 內部 function 的函式指標的問題,
程式碼如下:
#include <iostream>
#include <conio.h>
using namespace std;
class A
{
public:
void show(int value);
};
typedef struct
{
char name[20];
void (A::*ptr_fun)(int);
} S;
S s[] =
{
{"Show Data", &A::show}
};
void A::show(int value)
{
cout << value << endl;
};
int main()
{
s[0].ptr_fun(3);
getch();
return 0;
}
黃色部份一直出現編譯錯誤,
想請教是要如何修改才能成功? 這困擾了我ㄧ段時間...
感謝大家 !
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 211.23.86.187
→
11/01 14:41, , 1F
11/01 14:41, 1F
→
11/01 14:51, , 2F
11/01 14:51, 2F
→
11/01 14:52, , 3F
11/01 14:52, 3F
→
11/01 16:12, , 4F
11/01 16:12, 4F