fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. template<class T>
  5. class CMemoryPool
  6. {
  7. public:
  8. CMemoryPool(int param1)
  9. : stuff(param1)
  10. {}
  11.  
  12. private:
  13. T stuff;
  14. };
  15.  
  16. template<class T>
  17. class CList
  18. {
  19. public:
  20. struct Entry
  21. {
  22. T data;
  23. };
  24.  
  25. static CMemoryPool<Entry> s_pool;
  26. };
  27.  
  28. template<class T>
  29. CList<T>::CMemoryPool<typename CList<T>::Entry>::s_pool(1);
  30.  
  31. int main()
  32. {
  33. CList<int> list;
  34. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:29:11: error: non-template ‘CMemoryPool’ used as template
 CList<T>::CMemoryPool<typename CList<T>::Entry>::s_pool(1);
           ^
prog.cpp:29:11: note: use ‘CList<T>::template CMemoryPool’ to indicate that it is a template
prog.cpp:29:1: error: need ‘typename’ before ‘CList<T>::CMemoryPool’ because ‘CList<T>’ is a dependent scope
 CList<T>::CMemoryPool<typename CList<T>::Entry>::s_pool(1);
 ^
prog.cpp: In function ‘int main()’:
prog.cpp:33:16: warning: unused variable ‘list’ [-Wunused-variable]
     CList<int> list;
                ^
stdout
Standard output is empty