以下のコードスニペットから、私は関数のアドレスを取得しています。なぜですか?関数ポインタアドレスがC++のbool型で印刷されているのはなぜですか?
#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);
}
関数ポインタは、ブール値に暗黙的にキャストされます。最近同様の質問がありました。 – stefaanv
[coutで関数ポインタを印刷するには?](http://stackoverflow.com/questions/2064692/how-to-print-function-pointers-with-cout)の可能な複製 – stefaanv