【发布时间】:2015-12-16 00:57:15
【问题描述】:
我已经到处寻找解决方案,可能只是我不知道如何正确地表达它。
我希望这个firstFunction 在firstFunction 的参数中声明它的地址时调用otherFunction。
这是我的代码:
init.h:
class Ainit
{
//function to be passed into firstFunction
void test();
void firstFunction( void (Ainit::*otherFunction)() );
};
init.cpp:
void Ainit::firstFunction( void (Ainit::*otherFunction)() )
{
(Ainit::*otherFunction)();
}
Xcode:指向以下行中的*,错误为:Expected unqualified-id
(Ainit::*otherFunction)();
如何在firstFunction 中调用我传递给firstFunction 的方法?
【问题讨论】:
-
你如何想象你可以在没有对象的情况下使用指向成员函数的指针?
标签: c++ function pointers parameters void-pointers