Templated class: How to create instance and work with it? I have created a class like this:

#ifndef MyList_h
#define MyList_h

#include "Arduino.h"

template &lt;typename T&gt;
class MyList {
public:  
  MyList(void); 
  ~MyList(void);

  void addItem(T* item);

  //more stuff

};

#endif


And implementation is like this:

#include "Arduino.h"
#include "MyList.h"

template&lt;typename T&gt; MyList&lt;T&gt;::MyList(void) {
  // constructor implementation here
}

template&lt;typename T&gt; MyList&lt;T&gt;::~MyList(void) {
  // desctructor implementation here
}

template&lt;typename T&gt; void MyList&lt;T&gt;::addItem(T* item) {
  // function implementation here
}

// ...more stuff


In my .ino Sketch I'm doing this (found this solution in a C++ example):

#include "MyList.h"
MyList&lt;word&gt;* list = new MyList&lt;word&gt;(); // global scope
//... more stuff


But when compiling, Arduino IDE complains:


  Test.ino:5: undefined reference to `MyList::MyList()'


I googled a bit and found this alternative way for creating the instance:

ArrayList&lt;word&gt;* list;


Then there's no error, just compiles file. BUT as soon as I want to use this instance (=adding code) like this:

list-&gt;addItem(i);


compiler complains again:


  Test.ino:25: undefined reference to `MyList::addItem(unsigned int*)'


What's wrong? Why is this reference undefined? 

I tried another way:

ArrayList&lt;word&gt; list; // again global scope


But then the compiler also tells me:


  Test.ino:5: undefined reference to MyList&lt;unsigned
  int&gt;::MyList()' /tmp/ccp8qmCz.ltrans0.ltrans.o: In function
  _GLOBAL__sub_D_list':
  /....../Test.ino:5:
  undefined reference to `MyList::~MyList()'


So, how can I create an instance of my class that uses a template?



Environment: Arduino IDE 1.8.3 (I know, I could update...) + Arduino Nano Board.
I think I found the solution:

According to: https://stackoverflow.com/questions/8752837/undefined-reference-to-template-class-constructor

--> Put all implementation in .h file. That's it. No more compler complains, code runs fine.

I think I have to dig deeper into c/c++ development ...