Yur*_*rik 1 c++ function-pointers
我需要将此代码转换为Visual Studio 2008的函数指针调用GetValue()
.func可以是虚拟的,但并非总是如此,并且GetObject()
在不同的上下文中将返回不同的类型.
...
res = GetObject()->GetValue(x, y);
...
Run Code Online (Sandbox Code Playgroud)
调用函数将传入GetObject()->GetValue
(指向func的指针+应该调用该函数的对象实例),并且调用函数将提供参数:
void Foo( (int T::func*)(int, int) )
{
...
res = func(x, y);
...
}
void Bar()
{
Foo( & GetObject()->GetValue );
}
Run Code Online (Sandbox Code Playgroud)
谢谢!
归档时间: |
|
查看次数: |
909 次 |
最近记录: |