fork download
  1. #include <iostream>
  2.  
  3. template<class T>
  4. class Model
  5. {
  6. class Texture;
  7. public:
  8. T f(T);
  9. };
  10.  
  11. template<typename T>
  12. class Model<T>::Texture
  13. {
  14. //you should be able to use T here, even though Texture is not a template!
  15. public:
  16. T m_data; //T here
  17. Texture(T data) : m_data(data) //T here also!
  18. {}
  19. };
  20.  
  21. template<typename T>
  22. T Model<T>::f(T data)
  23. {
  24. Texture t(data);
  25. return t.m_data; //access member data
  26. }
  27.  
  28. int main() {
  29. Model<int> m;
  30. std::cout << m.f(100) << std::endl;
  31. return 0;
  32. }
Success #stdin #stdout 0.01s 2724KB
stdin
Standard input is empty
stdout
100