現在如何處理一個類的函數指針到另一個類的函數?這是我的問題爲什麼我不能用這個其他類的函數填充這個類的函數指針
例子:
class Apple
{
int(Apple::*pActionFunc)(void);
};
class Tree
{
Apple* tempy;
void Init(void);
int I_Work(void);
};
void Tree::Init(void)
{
tempy = new Apple();
tempy->pActionFunc = &Tree::I_Work;
}
int Tree::I_Work(void)
{
"Do Things"
}
這是行不通的。這是爲什麼?
爲什麼在使用函數或接口時使用函數指針? – AlexTheo 2012-01-27 15:07:47
http://blogs.msdn.com/b/oldnewthing/archive/2004/02/09/70002.aspx這是一個很好的關於方法指針的閱讀。無論如何,享受並希望它可以幫助 – Nico 2012-01-27 15:04:24