fork(5) download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. class base
  5. {
  6. public:
  7. template<class T> int func();
  8. // ^^^^^
  9. // use class keyword
  10.  
  11. }; // <-- semicolon here
  12.  
  13. template<class T>
  14. // ^^^^^
  15. // use class keyword
  16. int base::func()
  17. {
  18. cout << "base::func called" << endl;
  19. return 0;
  20. }
  21.  
  22. class derived : public base
  23. // ^
  24. // no colon here
  25. {
  26. public:
  27. void caller()
  28. {
  29. func<int>(); // it works
  30. base::func<int>(); // this works too
  31. }
  32. }; // <-- semicolon here
  33.  
  34.  
  35. int main()
  36. {
  37. derived d;
  38. d.caller();
  39. }
Success #stdin #stdout 0s 3468KB
stdin
Standard input is empty
stdout
base::func called
base::func called