関数ポインタを使用する場合は、ポインタは括弧直接呼び出しで同じ関数名、およびパラメータリストのようにすることができます。また、最初のリコールを逆参照
//include directories...
using namespace std;
void testFun()
{
cout<<"this is a test"<<endl;
}
int main(int argc,char**argv)
{
auto *pFun=testFun;
pFun();//or (*pFun)() is also fine
}
しかし、クラスのポインタを使用することはできません
//header files...
using namespace std;
class A
{
private:
int a;
public:
A(int a_):a(a_){}
void operator(){cout<<a<<endl;}
};
int main(int argc,char** argv)
{
A a1(5);
A *pA=new A(7);
a1();//correct using operator() function
(*pA)();//pA() is not correct
}