fork download
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. template <typename T>
  6. class Base {
  7. public:
  8. T t;
  9. void use() {cout << "base" << endl;};
  10. };
  11.  
  12. template <typename T>
  13. class Derived: public Base<T> {
  14.  
  15. public:
  16. using Base<T>::use;
  17. T x;
  18. void print() { use(); };
  19.  
  20. };
  21.  
  22. using namespace std;
  23.  
  24. int main() {
  25.  
  26. Derived<float> *s = new Derived<float>();
  27.  
  28. s->Base<float>::use(); // this is okay
  29. s->use(); // compiler complaints that "void Base<T>::use() is inaccessible"
  30.  
  31. s->print(); // this is okay
  32.  
  33. return 0;
  34. }
  35.  
  36.  
Success #stdin #stdout 0s 16064KB
stdin
Standard input is empty
stdout
base
base
base