title: C++ template "Field has incomplete type"
body: <p>I'm a beginner in C++, the following example code is very simple but I'm getting a puzzling error.  <code>Field has incomplete type "ItemType"</code> 
  <img src="https://i.stack.imgur.com/I37xv.png" alt="Error"></p>
  
  <p>The code is from Data Abstraction &amp; Problem Solving with C++ by Frank Carrano. Pg. 32 - 33, Pg. 37</p>
  
  <p>I'm using <code>Xcode 6.0 (6A267n)</code> on <code>OSX Yosemite Beta 10.10</code></p>
  
  <p>In header file (<a href="http://cs.smu.ca/~porter/csc/common_341_342/code/CarranoTextSourceCode6th/Interlude01/ListingC1_03/PlainBox.h" rel="nofollow noreferrer">Listing C1-03</a>)</p>
  
  <pre><code>/** @file PlainBox.h */
  
  #ifndef __PlainBox__
  #define __PlainBox__
  
  //Indicates this is a template definition
  template&lt;class ItemType&gt;
  // Declaration for the class PlainBox
  class PlainBox
  {
  private:
      // Data field
      ItemType item; //error here
  public:
      // Default constructor
      PlainBox();
  
      // Paramerized constructor
      PlainBox(const ItemType&amp; theItem);
  
      // Method to change the value of the data field
      void setItem(const ItemType&amp; theItem);
  
      // Method to return item form the data field
      ItemType getItem() const;
  
  };  // end PlainBox
  #include "PlainBox.cpp"
  #endif /* defined(__PlainBox__PlainBox__) */
  </code></pre>
  
  <p>In cpp file (<a href="http://cs.smu.ca/~porter/csc/common_341_342/code/CarranoTextSourceCode6th/Interlude01/ListingC1-04/PlainBox.cpp" rel="nofollow noreferrer">listing C1-04</a>)</p>
  
  <pre><code>/** @file PlainBox.cpp */
  #include "PlainBox.h"
  template&lt;class ItemType&gt;
  PlainBox &lt;ItemType&gt; :: PlainBox ()
  {
  }   //end default constructor
  template&lt;class ItemType&gt;
  PlainBox &lt;ItemType&gt; ::PlainBox(const ItemType&amp; theItem)
  {
      item = theItem;
  }   //end constructor
  template&lt;class ItemType&gt;
  void PlainBox &lt;ItemType&gt; ::setItem(const ItemType &amp;theItem)
  {
      item = theItem;
  }   //end setItem
  template&lt;class ItemType&gt;
  ItemType PlainBox &lt;ItemType&gt; ::getItem() const
  {
      return item;
  }   //end getItem
  </code></pre>
  
  <p>EDIT: Turns out I have to remove the .cpp file form the Xcode project and remove the <code>#include</code> in the .cpp file.</p>
  
  <p><img src="https://i.stack.imgur.com/qN3GH.png" alt="Xcode drop down menu">
  <img src="https://i.stack.imgur.com/XFvZd.png" alt="Remove Reference"></p>