If I have a base class with a pure-virtual function, and a derived class that implements that function – what’s the easiest way I can print out the address that the function actually gets called at?
class A { public: virtual void func()=0; }
class B:A {
public:
void func() { /*implementation*/ }
void func2() { *** I WANT TO PRINT THE ADDRESS OF func() HERE! *** }
};
Also, what’s the easiest way to print out the address of a static function in a class, and to print out the address of a global function?
[Edited] As far as I know, there’s no way to get the address of the function that actually will be called, regardless of virtualness. For virtual methods specifically, the method and destination of virtual dispatch is left to the implementation. However even for normal functions the function pointer may not be the actual code address of the function (although I suspect there are cases where it is).