fork(2) download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. class MyClass {
  5. int foo0() { return 0; }
  6. int foo1() { return 1; }
  7. template<int (MyClass::*fun)()> void test0() { const auto i = fun(); }
  8. void test1() { test0<&MyClass::foo0>(); }
  9. void test2() {
  10. const auto fun0 = &MyClass::test0<&MyClass::foo0>;
  11. const auto fun1 = &MyClass::test0<&MyClass::foo1>;
  12. fun0();
  13. fun1();
  14. }
  15. };
  16.  
  17. int main() {
  18. // your code goes here
  19. return 0;
  20. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In member function ‘void MyClass::test0()’:
prog.cpp:7:68: error: must use ‘.*’ or ‘->*’ to call pointer-to-member function in ‘fun (...)’, e.g. ‘(... ->* fun) (...)’
  template<int (MyClass::*fun)()> void test0() { const auto i = fun(); }
                                                                    ^
prog.cpp: In member function ‘void MyClass::test2()’:
prog.cpp:12:8: error: must use ‘.*’ or ‘->*’ to call pointer-to-member function in ‘fun0 (...)’, e.g. ‘(... ->* fun0) (...)’
   fun0();
        ^
prog.cpp:13:8: error: must use ‘.*’ or ‘->*’ to call pointer-to-member function in ‘fun1 (...)’, e.g. ‘(... ->* fun1) (...)’
   fun1();
        ^
stdout
Standard output is empty