fork download
  1. #include <iostream>
  2.  
  3.  
  4. template<class T>
  5. struct Base
  6. {
  7. typedef T type;
  8. static const int n = 3;
  9. virtual int f() = 0;
  10. int f(int x) { return x * 2; }
  11. };
  12.  
  13. template<class T>
  14. struct Derived : Base<T>
  15. {
  16. using typename Base<T>::type;
  17. using Base<T>::n;
  18.  
  19. type field;
  20. int f() { return n; }
  21. };
  22.  
  23.  
  24. int main()
  25. {
  26. Derived<float> d;
  27. d.field = 42.0f;
  28. std::cout << d.f();
  29. }
Success #stdin #stdout 0s 3340KB
stdin
Standard input is empty
stdout
3