How to print function pointers with cout?

前端 未结 7 2562
挽巷
挽巷 2020-11-22 07:09

I want to print out a function pointer using cout, and found it did not work. But it worked after I converting the function pointer to (void *), so does printf with %p, such

7条回答
  •  猫巷女王i
    2020-11-22 07:32

    Casting pointers to (void*) to print them to cout is the right thing (TM) to do in C++ if you want to see their values.

提交回复
热议问题