Print address of virtual member function

后端 未结 5 1281
眼角桃花
眼角桃花 2020-12-01 13:57

I am trying to print the address of a virtual member function. If I know which class implements the function I can write:

print(\"address: %p\", &A::func         


        
5条回答
  •  生来不讨喜
    2020-12-01 14:33

    From what I can tell in the standard, the only time you get dynamic binding is during a virtual function call. And once you've called a function, you're executing the statements within the function (i.e., you can't "stop halfway" into the call and get the address.)

    I think it's impossible.

提交回复
热议问题