title: Calling a method of a abstract class inside of a linked list fails
body: <p>I wrote a Class called cube which holds a double linked list which should hold objects of a abstract class called <code>Animation</code> and has a method to add animations . It looks liket his:</p>
  
  <pre><code>class CubeLib
  {
  protected:
  //some more variables 
      LinkedList&lt;Animation*&gt; animations; //a list of animations
  public:
      inline void addAnimation(Animation* a){
          animations.add(a);
      };
  }
  </code></pre>
  
  <p>The interface:</p>
  
  <pre><code>class Animation
  {
   public:
      virtual void update(short delta) = 0; 
  };
  </code></pre>
  
  <p>Inside of the ino of the arduino project i init the CubeLib and the Animation in global  and inside of the setup i add them to the list:</p>
  
  <pre><code>CubeLib cube;
  Sinus* sinus_ani =new Sinus(&amp;cube); // if not like this it stucks at setup?!
  void setup()
  {
      cube.addAnimation(sinus_ani);
  }
  </code></pre>
  
  <p>Inside of a method called render i call the current Animations update function.</p>
  
  <pre><code>inline void CubeLib::update(short delta)
  {
      if (animations.size() != -1){ //if its not empty
          animations[current_Animation]-&gt;update(delta);
      }
  }
  </code></pre>
  
  <p>But in this case it does happen nothing. The update of the Sinus does not get called.
  Last but not least here is my double linked list. (I tested it but maybe there is some issue with it?)</p>
  
  <pre><code>template &lt;typename T&gt;
  class LinkedList
  {
  protected:
  private:
      struct Node
      {
          Node* prev;
          Node* next;
          T value;
      };
  
      Node* last;
      Node* first;
      byte count;
  
  public:
      LinkedList()
      {
          count = -1; //empty
      };
  
      ~LinkedList()
      {
          if (count &gt; -1){
              clear();
          }
      };
      /** adds to list*/
      inline void add(T t);
  
      /**removes the thing at index*/
      inline T remove(int index);
  
      /** Returns NULL(ptr) if index is out of range or item not found somehow*/
      inline T get(int index);
  
      inline void clear();
  
      /**Returns the first obj*/
      inline T getFirst();
  
      /**Returns the last obj*/
      inline T getLast();
  
      /**Returns the current size. If -1 its empty!*/
      inline int size(){
          return count;
      };
  
      T operator[](const int i)
      {
          return get(i);
      };
  };
  
  template &lt;typename T&gt;
  inline void LinkedList&lt;T&gt;::add(T t){
      Node* n = new Node();
      n-&gt;value = t;
      if (count &gt; -1)
      {
          n-&gt;next = first;
          n-&gt;prev = last;
          last-&gt;next = n;
          last = n;
          count++;
      }
      else if (count == -1)//first element
      {
          first = n;
          first-&gt;next = n;
          first-&gt;prev = n;
          last = n;
          last-&gt;next = n;
          last-&gt;prev = n;
          count++;
      }
  }
  
  template &lt;typename T&gt;
  inline T LinkedList&lt;T&gt;::remove(int index){
      if (index &lt;= count)
      {
          Node* n = last;
          for (int i = 0; i &lt;= index; i++)
          {
              n = n-&gt;next;
          }
          n-&gt;prev-&gt;next = n-&gt;next;
          n-&gt;next-&gt;prev = n-&gt;prev;
          count--;
          return n-&gt;value; //return the value of that node
      }
  }
  
  template &lt;typename T&gt;
  inline T LinkedList&lt;T&gt;::get(int index){
      if (index &lt;= count &amp;&amp; index &gt; -1)
      {
          Node* n = first;
          int i = 0;
          while (i &lt; index)
          {
              n = n-&gt;next;
              i++;
          }
          return n-&gt;value;
      }
      return NULL;
  }
  
  template &lt;typename T&gt;
  inline void LinkedList&lt;T&gt;::clear()
  {
      Node* n = first;
      while (count &gt; 0)
      {
          Node* toBeDeleted = n;
          n = n-&gt;next;
          delete toBeDeleted;
          count--;
      }
  }
  /**Returns the first obj*/
  template &lt;typename T&gt;
  inline T LinkedList&lt;T&gt;::getFirst()
  {
      return first-&gt;value;
  };
  
  /**Returns the last obj*/
  template &lt;typename T&gt;
  inline T LinkedList&lt;T&gt;::getLast()
  {
      return last-&gt;value;
  };
  </code></pre>
  
  <p>I am sorry for alot of code here. And I hope its not a obvious failer.</p>
  
  <hr>
  
  <p>Edit:</p>
  
  <p>Sinus is declared liket his:</p>
  
  <pre><code>class Sinus : public Animation
  {
  private:
      RGB color;
      CubeLib* cube;
      byte colorcounter;
      float time;
  
  public:
      Sinus(CubeLib* c) : time(0.0), colorcounter(0), cube(c){
          color.r = MAX_COLOR;
          color.g = MAX_COLOR;
          color.b = MAX_COLOR;
      };
      ~Sinus(){};
      void update(short delta);
  };
  
  void Sinus::update(short delta)
  {
      //do this 1000 times
      time += (((float)delta)/1000.0);
      for (int x = 0; x &lt; 5; x++)
      {
          float value = (2.0*sin((float)(x + 1)*time*12.0)) + 2.0;
          for (int y = 0; y &lt; 5; y++)
          {
              for (int z = 0; z &lt; 5; z++)
              {
                  if (abs(((float)z) - value) &lt; 0.5)
                  {
                      //cube.setLED(x, y, z, depth - 30/5*(int)abs(z-value), 0, 0);
                      cube-&gt;setLED(x, y, z, color);
                  }
                  else
                  {
                      cube-&gt;setLED(x, y, z, 0, 0, 0);
                  }
              }
          }
      }
  
      colorcounter++;
      if (colorcounter &gt; 25)
      {
          color.r = random(MAX_COLOR);
          color.g = random(MAX_COLOR);
          color.b = random(MAX_COLOR);
          colorcounter = 0;
      }
  }
  </code></pre>