fork download
  1. #include <iostream>
  2.  
  3. struct MyBase
  4. {
  5. virtual void DoStuff(int, float) { std::cout << "Base" << std::endl; }
  6. };
  7.  
  8. struct MyDerived : MyBase
  9. {
  10. virtual void DoStuff(int, float) { std::cout << "Derived" << std::endl; }
  11. };
  12.  
  13. int main()
  14. {
  15. typedef void (MyBase::*memfun)(int, float);
  16.  
  17. memfun event(&MyBase::DoStuff);
  18.  
  19. MyBase base;
  20. MyDerived derived;
  21.  
  22. (base.*event)(42, 3.14);
  23. (derived.*event)(42, 3.14);
  24. }
  25.  
Success #stdin #stdout 0s 2724KB
stdin
Standard input is empty
stdout
Base
Derived