小编Abd*_*f K的帖子

为什么函数指针地址在c ++中以bool类型打印?

从下面的代码片段我得到的函数的地址是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);
}
Run Code Online (Sandbox Code Playgroud)

c++

4
推荐指数
1
解决办法
181
查看次数

标签 统计

c++ ×1