功能指针带&没有

时间:2015-01-04 15:11:46

标签: c++ pointers function-pointers

有什么区别:

int (*wskNaF)(int, int) = addition;

和这一行

int (*wskNaF)(int, int) = &addition;
分数完全相同:

#include <cstdio>

int addition( int a, int b );

int (*wskNaF)(int, int) = addition;
//int (*wskNaF)(int, int) = &addition;

int main()
{
  printf("Score= %d\n", wskNaF(5,7));
  return 0;
}

int addition( int a, int b )
{
  return a + b;
}
// g++ test.cpp -o test && ./test

我认为函数名也是她的指针?我错了吗?

0 个答案:

没有答案