title: Error while overloading operator (must be a nonstatic member function)
body: <p>I'm writing string class on my own. And I have such code. I just want to overload <code>operator=</code>. This is my actual code, and I get error in last part of code.</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;string.h&gt;
  #include &lt;stdlib.h&gt;
  
  using namespace std;
  
  class S {
      public:
          S();
          ~S() { delete []string;}
          S &amp;operator =(const S &amp;s);
  
      private:
          char *string;
          int l;
  };
  
  S::S()
  {
      l = 0;
      string = new char[1];
      string[0]='\0';
  }
  
  S &amp;operator=(const S &amp;s)
  {
      if (this != &amp;s)
      {
          delete []string;
          string = new char[s.l+1];
          memcpy(string,s.string,s.l+1);
          return *this;
      }
      return *this;
  }
  </code></pre>
  
  <p>But unfortunately I get error 'S&amp; operator=(const S&amp;)' must be a nonstatic member function.</p>