C++ 为什么函数指针地址在c++;?

C++ 为什么函数指针地址在c++;?,c++,C++,从下面的代码片段中,我得到的函数地址是1。为什么? #include<iostream> using namespace std; int add(int x, int y) { int z; z = x+y; cout<<"Ans:"<<z<<endl; } int main() { int a=10, b= 10; int (*func_ptr) (int,int); func_ptr = &add;

从下面的代码片段中,我得到的函数地址是1。为什么?

#include<iostream>
using namespace std;
int  add(int x, int y)
{
  int z;
  z = x+y;
  cout<<"Ans:"<<z<<endl;
}

int main()
{
  int a=10, b= 10;
  int (*func_ptr) (int,int);
  func_ptr  = &add;
  cout<<"The address of function add()is :"<<func_ptr<<endl;
  (*func_ptr) (a,b);
}
#包括
使用名称空间std;
整数相加(整数x,整数y)
{
intz;
z=x+y;
cout使用的过载是

ostream& ostream::operator<< (bool val);

ostream&ostream::operator函数指针不能转换为数据指针。如果尝试将一个指针分配给
void*
变量,则会出现编译器错误。但它们可以隐式转换为
bool


这就是为什么
运算符的
bool
重载函数指针隐式转换为boolean的原因。最近有一个类似的问题,可能是
#include<iostream>
using namespace std;
int  add(int x, int y)
{
  int z;
  z = x+y;
  cout<<"Ans:"<<z<<endl;
}

int main()
{
  int a=10, b= 10;
  int (*func_ptr) (int,int);
  func_ptr  = &add;
  cout<<"The address of function add()is :"<< reinterpret_cast<void*>(func_ptr) <<endl;
  (*func_ptr) (a,b);
}