fork download
  1. #include <iostream>
  2.  
  3. template <typename T> struct A
  4. {
  5. T x;
  6. A(T X) : x(X) { }
  7. static const A a;
  8. };
  9. template <typename T> const A<T> A<T>::a(5);
  10.  
  11. template <typename T> struct B : public A<T>
  12. {
  13. B(T X) : A<T>(X) { }
  14. static const B b;
  15. };
  16. template <typename T> const B<T> B<T>::b(A<T>::a.x);
  17.  
  18. int main()
  19. {
  20. //auto test0 = A<int>::a.x;
  21. auto test1 = B<int>::a.x;
  22. auto test2 = B<int>::b.x;
  23. auto test3 = A<int>::a.x;
  24. std::cout << "test1 = " << test1 << "\ttest2 = " << test2 << "\ttest3 = " << test3 << std::endl;
  25.  
  26. return 0;
  27. }
Success #stdin #stdout 0s 3412KB
stdin
Standard input is empty
stdout
test1 = 5	test2 = 5	test3 = 5