fork(4) download
  1. #include <iostream>
  2. #include <sstream>
  3. #include <list>
  4. #include <vector>
  5. //using namespace std;
  6. template<typename T, typename R>
  7. class tContainer_t
  8. {
  9. R Container;
  10. public:
  11. tContainer_t();
  12. ~tContainer_t();
  13.  
  14. bool IsEmpty();
  15. T GetFirst();
  16. T GetLast();
  17. int Size();
  18. void Insert(T* element);
  19. std::string Print();
  20.  
  21. };
  22.  
  23. template<typename T, typename R>
  24. std::string tContainer_t<T, R>::Print()
  25. {
  26. std::ostringstream s;
  27. s << "[";
  28. typename R<T*>::const_iterator it;
  29. for(it = Container.begin(); it != Container.end(); it++)
  30. {
  31. s << (**it);
  32. }
  33. return s.str();
  34. }
  35.  
  36. template<typename T, typename R>
  37. void tContainer_t<T, R>::Insert( T* element )
  38. {
  39. Container.push_back(element);
  40. }
  41.  
  42. template<typename T, typename R>
  43. int tContainer_t<T, R>::Size()
  44. {
  45. return R.size();
  46. }
  47.  
  48. template<typename T, typename R>
  49. T tContainer_t<T, R>::GetLast()
  50. {
  51. //R<T*>::const_iterator it = Container.end();
  52. return Container.end();
  53. }
  54.  
  55. template<typename T, typename R>
  56. T tContainer_t<T, R>::GetFirst()
  57. {
  58.  
  59. }
  60.  
  61. template<typename T, typename R>
  62. bool tContainer_t<T, R>::IsEmpty()
  63. {
  64. R.empty()
  65. }
  66.  
  67. //CTOR
  68. template<typename T, typename R>
  69. tContainer_t<T, R>::tContainer_t() : Container()
  70. {
  71.  
  72. }
  73. //DTOR
  74. template<typename T, typename R>
  75. tContainer_t<T, R>::~tContainer_t()
  76. {
  77.  
  78. }
  79.  
  80. int main()
  81. {
  82. tContainer_t<int, std::list<int*> > l;
  83. int i1 = 1;
  84. int i2 = 2;
  85. l.Insert(&i1);
  86. l.Insert(&i2);
  87. l.Print();
  88. return 0;
  89. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In member function ‘std::string tContainer_t<T, R>::Print()’:
prog.cpp:28: error: expected initializer before ‘<’ token
prog.cpp:29: error: ‘it’ was not declared in this scope
prog.cpp: In member function ‘int tContainer_t<T, R>::Size()’:
prog.cpp:45: error: expected primary-expression before ‘.’ token
prog.cpp: In member function ‘bool tContainer_t<T, R>::IsEmpty()’:
prog.cpp:64: error: expected unqualified-id before ‘.’ token
prog.cpp:65: warning: no return statement in function returning non-void
stdout
Standard output is empty