fork download
  1. #include <iostream>
  2.  
  3. template <typename T>
  4. class A {
  5. public:
  6. A(T* t) : t_(t) {}
  7.  
  8. protected:
  9. T* t_;
  10. };
  11.  
  12. template <typename T>
  13. class B : public A<T> {
  14. public:
  15. B(T* t) : A<T>(t) {}
  16.  
  17. T get() { return *t_; }
  18. };
  19.  
  20. int main()
  21. {
  22. int i = 4;
  23. B<int> b(&i);
  24. std::cout << b.get() << std::endl;
  25. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:17:20: error: use of undeclared identifier 't_'
        T get() { return *t_; }
                          ^
1 error generated.
stdout
Standard output is empty