Why do function pointers all have the same value?

前端 未结 4 539
难免孤独
难免孤独 2021-01-23 05:30

For example:

using namespace std;
#include 

void funcOne() {
}

void funcTwo( int x ) {
}

int main() {

  void (*ptrOne)() = funcOne;
  cout &l         


        
4条回答
  •  庸人自扰
    2021-01-23 05:46

    Use it like this, or it will be converted to a bool type.

    cout << reinterpret_cast(ptrOne) << endl;
    

提交回复
热议问题