fork download
  1. template<int X, int Y>
  2. struct S
  3. {
  4. typedef int func(int,float) const;
  5. };
  6.  
  7. template<int X>
  8. struct D : public S<X,6>
  9. {
  10. typename S<7,6>::func func;
  11. };
  12. template<int X>
  13. int D<X>::func(int,float) const
  14. {
  15. return 1;
  16. }
  17. //----------------
  18. struct W : public S<7,8>
  19. {
  20. S<7,8>::func func;
  21. };
  22. int W::func(int,float) const
  23. {
  24. return 2;
  25. }
  26.  
  27. #include <iostream>
  28. int main()
  29. {
  30. W w;
  31. std::cout << w.func(1,4.3) << "\n";
  32. D<3> d;
  33. std::cout << d.func(1,4.3) << "\n";
  34. }
Success #stdin #stdout 0s 3456KB
stdin
Standard input is empty
stdout
2
1