fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. struct Test
  5. {
  6. void Method1()
  7. {
  8. cout << __FUNCTION__ << endl;
  9. }
  10. void Method2()
  11. {
  12. cout << __FUNCTION__ << endl;
  13. }
  14. };
  15.  
  16. void CallMethod(Test &test, void (Test::*p)())
  17. {
  18. (test.*p)();
  19. }
  20.  
  21. int main() {
  22. Test test;
  23. printf("%u\n", sizeof(&Test::Method1));
  24. printf("%u\n", sizeof(&main));
  25. CallMethod(test, &Test::Method1);
  26. CallMethod(test, &Test::Method2);
  27. return 0;
  28. }
Success #stdin #stdout 0s 15232KB
stdin
Standard input is empty
stdout
16
8
Method1
Method2