title: name followed by :: must be a class or namespace but header defined
body: <p>I am trying to implement some methods that have been declared in my header file in my source file.</p>
  <p>I keep getting this error</p>
  <pre><code>name followed by :: must be a class or namespace
  </code></pre>
  <p>and from searching it seems like a project setup error, however both my files are in the correct directory.</p>
  <p><strong>main</strong></p>
  <pre><code>#include &quot;sarray.h&quot;
  #include &lt;iostream&gt;
  using namespace std;
  template&lt;class genericData&gt;
  sarray::sarray(int size)
  {
      if (size &gt; 0) genericData data = new int[size];
      else {
          cout &lt;&lt; &quot;illegal array size = &quot; &lt;&lt; size &lt;&lt; endl;
          exit(1);
      }
  }
  template&lt;class genericData&gt;
  sarray::~sarray()
  {
      delete[] data;
  }
  template&lt;class genericData&gt;
  int&amp; sarray::operator[](int i)
  {
      if (i &lt; 0 || i &gt;= size) {
          cout &lt;&lt; &quot;index &quot; &lt;&lt; i &lt;&lt; &quot; is out of bounds.&quot; &lt;&lt; endl;
          exit(1);
      }
      return data[i];
  }
  int main()
  {
      // create a 10-element safe array
      sarray myArray = sarray(10);
      sarray array(10);
      // in-bound access, [] is used on the left side or an assignment
      array[5] = 23;
      // in-bound access, [] is used on the right side of an operation
      cout &lt;&lt; array[5] &lt;&lt; endl;
      // out-of-bound accesses
      array[13] = 392;
      cout &lt;&lt; array[-1] &lt;&lt; endl;
      return 0;
  }
  </code></pre>
  <p><strong>sarray.h</strong></p>
  <pre><code>#ifndef SARRAYS_H
  #define SARRAYS_H
  
  template&lt;class genericData&gt;
  class sarray {
  public:
      sarray(int size);
      ~sarray();
      &amp; operator[](int i);
  private:
      int size;
      genericData* data;
  };
  #endif // !sarrays
  </code></pre>