title: Apple mach-o linker (id) error with C++
body: <p>I created a new project in <strong>Xcode 5.0</strong> to implement a Queue class as following:
  I created a .h file called QueueArray.h and it contains the following:</p>
  
  <pre><code>#ifndef __Queue__QueueArray__
  #define __Queue__QueueArray__
  
  #include &lt;iostream&gt;
  
  template &lt;class T&gt;
  class QueueArray
  {
  public:
      QueueArray(int cap);
      ~QueueArray();
  
      void Enqueue(T&amp; val);
      T Dequeue(void);
      T GetFirst(void);
      T GetLast(void);
      bool IsEmpty(void);
      bool IsFull(void);
      void Clear(void);
  
  private:
      T* data;
      int capacity, size, first, last;
  };
  
  #endif
  </code></pre>
  
  <p>and a .cpp file called QueueArray.cpp that contains the following:</p>
  
  <pre><code>#include "QueueArray.h"
  using namespace std;
  
  template &lt;class T&gt;
  QueueArray&lt;T&gt;::QueueArray(int cap)
  {
      capacity = cap;
      data = new T[capacity];
      size = 0;
      first = last = -1;
  }
  
  template &lt;class T&gt;
  QueueArray&lt;T&gt;::~QueueArray(void)
  {
      delete [] data;
  }
  
  template &lt;class T&gt;
  void QueueArray&lt;T&gt;::Enqueue(T&amp; el)
  {
      if(IsFull() == true)
      {
          printf("\n Can't enqueue into a full queue!");
          return;
      }
      if(IsEmpty() == true)
          first = last = 0;
      else if(last == capacity-1)//if at the last entry
          last = 0; //wrap around to the first entry
      else
          last++;
      data[last] = el;
      size++;
  }
  
  template &lt;class T&gt;
  T QueueArray&lt;T&gt;::Dequeue()
  {
      if(IsEmpty() == true)
      {
          printf("\n Can't dequeue from an empty queue!");
          return -1;
      }
      T el = data[first];
      if(first == last) //if only one element in queue
          last = first = -1; //we'll get an empty queue
      else if(first == capacity-1) //if at the last entry
          first = 0; //wrap around to the first entry
      else //normal case
          first++;
      size--;
      return el;
  }
  
  template &lt;class T&gt;
  T QueueArray&lt;T&gt;::GetFirst()
  {
      return data[first];
  }
  
  template &lt;class T&gt;
  T QueueArray&lt;T&gt;::GetLast()
  {
      return data[last];
  }
  
  template &lt;class T&gt;
  bool QueueArray&lt;T&gt;::IsEmpty(void)
  {
      return size == 0;
  }
  
  template &lt;class T&gt;
  bool QueueArray&lt;T&gt;::IsFull(void)
  {
      return size == capacity;
  }
  </code></pre>
  
  <p>and a main.cpp file that contains the following:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include "QueueArray.h"
  using namespace std;
  
  int main(int argc, const char * argv[])
  {
      QueueArray&lt;int&gt; q(100);
      for (int i=0; i&lt;100; i++)
      {
          q.Enqueue(i);
      }
      for (int i=0; i&lt;100; i++) {
          cout&lt;&lt;q.Dequeue()&lt;&lt;endl;
      }
      return 0;
  }
  </code></pre>
  
  <p>When I try to run the project, a message appears saying "Build Failed" and here is a screenshot of the errors:</p>
  
  <p><img src="https://i.stack.imgur.com/SRx8I.png" alt="Screenshot"></p>
  
  <p>How to fix that?</p>