我有一個簡單的類,如下所述。模板函數將參數函數指針指向一個類方法
typedef mytype int;
typedef mytype2 float;
class A {
.
.
void run (mytype t) { .... do something with t ..... }
.
.
}
我其中我已創建的模板函數(使它獨立A類),其應該採取函數指針(即A類方法運行)及其參數沿另一個類。
class B {
.
template< // how it should be defined >
void myfunction (// how parameters will be passed) { }
驅動程序應該是這樣的
A a
B b
C c
b.myfunction(&A::run, mytype); // Or how it should be called
b.myfunction(&B::run, mytype2); // - do -
想法/代碼/原因?
Regards, Farrukh Arshad。