Guest User

Untitled

a guest
Jul 6th, 2012
27
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. Base class template instantiation depending on derived class constructor argument type
  2. template <class T>
  3. class foo
  4. {
  5. int a;
  6. public:
  7. foo(T a){}
  8. // When I convert the constructor to a function template, it works fine.
  9. // template <typename T> foo(T a){}
  10. };
  11.  
  12. class bar : public foo<class T>
  13. {
  14. public:
  15. bar(int a):foo(a){}
  16. };
  17.  
  18. int main(void)
  19. {
  20. bar obj(10);
  21. system("pause");
  22. return 0;
  23. }
  24.  
  25. template<class T>
  26. class bar : public foo<T>
  27. {
  28. public:
  29. bar(int a):foo(a){}
  30. };
  31.  
  32.  
  33. int main()
  34. {
  35. bar<int> obj(10);
  36. }
  37.  
  38. class bar : public foo<int>
  39. {
  40. public:
  41. bar(int a):foo(a){}
  42. };
  43.  
  44.  
  45. int main()
  46. {
  47. bar obj(10);
  48. }
Advertisement
Add Comment
Please, Sign In to add comment