我有一个简单的类,如下所述。模板函数将参数函数指针指向一个类方法
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。