C++ Pointer to virtual function
问题 If you have a struct like this one struct A { void func(); }; and a reference like this one A& a; you can get a pointer to its func method like this: someMethod(&A::func); Now what if that method is virtual and you don't know what it is at run-time? Why can't you get a pointer like this? someMethod(&a.func); Is it possible to get a pointer to that method? 回答1: Pointers to members take into account the virtuality of the functions they point at. For example: #include <iostream> struct Base {