fork download
  1. #include <iostream>
  2.  
  3. struct Base
  4. {
  5. void test( void (Base::*fncPtr)() )
  6. {
  7. (this->*fncPtr)();
  8. }
  9. };
  10.  
  11. struct Derived : public Base
  12. {
  13. void method()
  14. {
  15. std::cout << "it works";
  16. }
  17. };
  18.  
  19. int main()
  20. {
  21. Derived d;
  22. d.test(static_cast<void (Base::*)()>(&Derived::method));
  23. }
Success #stdin #stdout 0s 3468KB
stdin
Standard input is empty
stdout
it works