title: Overriding << operator not recognised
body: <p>I have defined this function in my header of the class ContextFreeGrammar: </p>
  
  <pre><code>friend ContextFreeGrammar &amp; operator&lt;&lt;(ContextFreeGrammar &amp; cfg, string toRead);
  </code></pre>
  
  <p>and it is implemented in the cpp file as :</p>
  
  <pre><code>ContextFreeGrammar &amp; operator&lt;&lt;(ContextFreeGrammar &amp; cfg, string toRead)
  {
  
    if (toRead[0] == 'I')
    {
      string parsedNameOfVariable = Variable::parseLabel(toRead.substr(1, toRead.length() - 1));
      cfg.setInitialVariable(Variable(parsedNameOfVariable));
      return cfg;
  }
  
  
    Rule newRule = Rule::parseLabel(toRead);
  
    cfg.addRule(newRule);
  
    return cfg;
  }
  </code></pre>
  
  <p>however in the main() when I create this object and initalize it (ContextFreeGrammar.h is imported) : </p>
  
  <pre><code>    ContextFreeGrammar cfg;
  
          cfg &lt;&lt; "{A}-&gt;{B}"
              &lt;&lt; "{B}-&gt;{C}"
              &lt;&lt; "{C}-&gt;{D}"
              &lt;&lt; "{D}-&gt;a{N}"
              &lt;&lt; "{B}-&gt;c";
  </code></pre>
  
  <p>I get this error :|undefined reference to `operator&lt;&lt;(ContextFreeGrammar&amp;, std::__cxx11::basic_string, std::allocator >)'|</p>