0

I have implemented working template class LList< T> and now I want object of this template class to be a property of a new class called Factory2. Here is how my Factory2 class looks like

#include "LList.h"
template<typename T>
class Factory2
{
public:
    Factory2();
   ~Factory2();
private:
    LList<T> arr;
 };

I have defined the constructor and destructor of Factory2 but how should I implement them for the LList< T> arr object? The LList< T> class has it's own constructor and destructor. I get the error:undefined reference to the constructor of LList<int>::LList() and LList<int>::~LList()

Jason Roman
  • 8,146
  • 10
  • 35
  • 40
  • My guess is, you've implemented methods of `LList` in a separate source file. That ain't gonna work - templates must be implemented in a header. The compiler needs to see the full definition at the point where the template is actually used and its parameters become known. – Igor Tandetnik Aug 19 '17 at 22:51
  • @IgorTandetnik for the LList class I have defined the methods in the header file and implemented them in the LList.cpp file – Pavel P. Aug 19 '17 at 22:56
  • Like I said, move implementations to the header. – Igor Tandetnik Aug 19 '17 at 22:57
  • Thanks,it worked. – Pavel P. Aug 19 '17 at 23:04

0 Answers0