fork download
  1. template <typename T>
  2. struct Base {
  3. T value;
  4. Base(T value) : value(value) { }
  5. };
  6.  
  7. template <typename T>
  8. struct Test : public Base<T> {
  9. typedef Base<T> parent;
  10. T getValue() { return this->value; } // why do I need to use parent:: here?
  11. Test(T value) : parent(value) { }
  12. };
  13.  
  14. #include <iostream>
  15. int main()
  16. {
  17. Test<int> t(1);
  18. std::cout << t.getValue() <<std::endl;
  19. }
Success #stdin #stdout 0.02s 2724KB
stdin
Standard input is empty
stdout
1