我已经定义了一些函数,我打印他们的地址是这样的:
#include<iostream>
#include <string>
using std::cout;
std::string func()
{
return "hello world\n";
}
int func2(int n)
{
if (n==0)
{
cout << func2 << std::endl;
return 1;
}
cout << func2 << std::endl;
return n + func2(n - 1);
}
//================================================
int main()
{
int (*fun)(int) = func2;
cout << fun;
cout << std::endl << func2(3);
}
Run Code Online (Sandbox Code Playgroud)
当我打印函数的名称(地址)时,它们都1
在我的编译器上打印(Mingw gcc 4.8).
它可以或它应该有所不同吗?