fork download
  1. #include <iostream>
  2. #include <typeinfo>
  3. using namespace std;
  4.  
  5.  
  6. class Base
  7. {
  8. public:
  9. void doStuff() {}
  10. };
  11.  
  12. class Derived : private Base
  13. {
  14. public:
  15. // Using older access declaration (without using) shoots a warning
  16. // and results in the same compilation error
  17. using Base::doStuff;
  18. };
  19.  
  20. template<class C, typename Func>
  21. void exec(C *c, Func func)
  22. {
  23. (c->*func)();
  24. }
  25.  
  26. int main()
  27. {
  28. Derived d;
  29. // Until here, everything compiles fine
  30. d.doStuff();
  31. // For some reason, I can't access the function pointer
  32. //exec(&d,&Derived::doStuff);
  33. cout << typeid(&Derived::doStuff).name() << endl << typeid(&Base::doStuff).name() << endl;
  34.  
  35. return 0;
  36.  
  37.  
  38.  
  39.  
  40. }
Success #stdin #stdout 0s 3140KB
stdin
Standard input is empty
stdout
M4BaseFvvE
M4BaseFvvE